Skip to content

Tower of Hanoi with 9 Disks

The shortest solution is 511 moves. Play them on the board, or read every one in the list under it.

Optimal solution

511moves2⁹ − 1

First move
Disk 1, A → C
At one move a second
8 minutes
Difficulty
Expert

9 disks on tower A. 511 moves to go.Step 0 of 511

Every move of the 9-disk solution
MoveDiskFromTo
11AC
22AB
31CB
43AC
51BA
62BC
71AC
84AB
91CB
102CA
111BA
123CB
131AC
142AB
151CB
165AC
171BA
182BC
191AC
203BA
211CB
222CA
231BA
244BC
251AC
262AB
271CB
283AC
291BA
302BC
311AC
326AB
331CB
342CA
351BA
363CB
371AC
382AB
391CB
404CA
411BA
422BC
431AC
443BA
451CB
462CA
471BA
485CB
491AC
502AB
511CB
523AC
531BA
542BC
551AC
564AB
571CB
582CA
591BA
603CB
611AC
622AB
631CB
647AC
651BA
662BC
671AC
683BA
691CB
702CA
711BA
724BC
731AC
742AB
751CB
763AC
771BA
782BC
791AC
805BA
811CB
822CA
831BA
843CB
851AC
862AB
871CB
884CA
891BA
902BC
911AC
923BA
931CB
942CA
951BA
966BC
971AC
982AB
991CB
1003AC
1011BA
1022BC
1031AC
1044AB
1051CB
1062CA
1071BA
1083CB
1091AC
1102AB
1111CB
1125AC
1131BA
1142BC
1151AC
1163BA
1171CB
1182CA
1191BA
1204BC
1211AC
1222AB
1231CB
1243AC
1251BA
1262BC
1271AC
1288AB
1291CB
1302CA
1311BA
1323CB
1331AC
1342AB
1351CB
1364CA
1371BA
1382BC
1391AC
1403BA
1411CB
1422CA
1431BA
1445CB
1451AC
1462AB
1471CB
1483AC
1491BA
1502BC
1511AC
1524AB
1531CB
1542CA
1551BA
1563CB
1571AC
1582AB
1591CB
1606CA
1611BA
1622BC
1631AC
1643BA
1651CB
1662CA
1671BA
1684BC
1691AC
1702AB
1711CB
1723AC
1731BA
1742BC
1751AC
1765BA
1771CB
1782CA
1791BA
1803CB
1811AC
1822AB
1831CB
1844CA
1851BA
1862BC
1871AC
1883BA
1891CB
1902CA
1911BA
1927CB
1931AC
1942AB
1951CB
1963AC
1971BA
1982BC
1991AC
2004AB
2011CB
2022CA
2031BA
2043CB
2051AC
2062AB
2071CB
2085AC
2091BA
2102BC
2111AC
2123BA
2131CB
2142CA
2151BA
2164BC
2171AC
2182AB
2191CB
2203AC
2211BA
2222BC
2231AC
2246AB
2251CB
2262CA
2271BA
2283CB
2291AC
2302AB
2311CB
2324CA
2331BA
2342BC
2351AC
2363BA
2371CB
2382CA
2391BA
2405CB
2411AC
2422AB
2431CB
2443AC
2451BA
2462BC
2471AC
2484AB
2491CB
2502CA
2511BA
2523CB
2531AC
2542AB
2551CB
2569AC
2571BA
2582BC
2591AC
2603BA
2611CB
2622CA
2631BA
2644BC
2651AC
2662AB
2671CB
2683AC
2691BA
2702BC
2711AC
2725BA
2731CB
2742CA
2751BA
2763CB
2771AC
2782AB
2791CB
2804CA
2811BA
2822BC
2831AC
2843BA
2851CB
2862CA
2871BA
2886BC
2891AC
2902AB
2911CB
2923AC
2931BA
2942BC
2951AC
2964AB
2971CB
2982CA
2991BA
3003CB
3011AC
3022AB
3031CB
3045AC
3051BA
3062BC
3071AC
3083BA
3091CB
3102CA
3111BA
3124BC
3131AC
3142AB
3151CB
3163AC
3171BA
3182BC
3191AC
3207BA
3211CB
3222CA
3231BA
3243CB
3251AC
3262AB
3271CB
3284CA
3291BA
3302BC
3311AC
3323BA
3331CB
3342CA
3351BA
3365CB
3371AC
3382AB
3391CB
3403AC
3411BA
3422BC
3431AC
3444AB
3451CB
3462CA
3471BA
3483CB
3491AC
3502AB
3511CB
3526CA
3531BA
3542BC
3551AC
3563BA
3571CB
3582CA
3591BA
3604BC
3611AC
3622AB
3631CB
3643AC
3651BA
3662BC
3671AC
3685BA
3691CB
3702CA
3711BA
3723CB
3731AC
3742AB
3751CB
3764CA
3771BA
3782BC
3791AC
3803BA
3811CB
3822CA
3831BA
3848BC
3851AC
3862AB
3871CB
3883AC
3891BA
3902BC
3911AC
3924AB
3931CB
3942CA
3951BA
3963CB
3971AC
3982AB
3991CB
4005AC
4011BA
4022BC
4031AC
4043BA
4051CB
4062CA
4071BA
4084BC
4091AC
4102AB
4111CB
4123AC
4131BA
4142BC
4151AC
4166AB
4171CB
4182CA
4191BA
4203CB
4211AC
4222AB
4231CB
4244CA
4251BA
4262BC
4271AC
4283BA
4291CB
4302CA
4311BA
4325CB
4331AC
4342AB
4351CB
4363AC
4371BA
4382BC
4391AC
4404AB
4411CB
4422CA
4431BA
4443CB
4451AC
4462AB
4471CB
4487AC
4491BA
4502BC
4511AC
4523BA
4531CB
4542CA
4551BA
4564BC
4571AC
4582AB
4591CB
4603AC
4611BA
4622BC
4631AC
4645BA
4651CB
4662CA
4671BA
4683CB
4691AC
4702AB
4711CB
4724CA
4731BA
4742BC
4751AC
4763BA
4771CB
4782CA
4791BA
4806BC
4811AC
4822AB
4831CB
4843AC
4851BA
4862BC
4871AC
4884AB
4891CB
4902CA
4911BA
4923CB
4931AC
4942AB
4951CB
4965AC
4971BA
4982BC
4991AC
5003BA
5011CB
5022CA
5031BA
5044BC
5051AC
5062AB
5071CB
5083AC
5091BA
5102BC
5111AC
On this page
  1. The solution
  2. The shape of the solution
  3. Which disk moves when
  4. The smallest disk's circuit
  5. About the 9-disk puzzle
  6. Other sizes
  7. Frequently asked questions

The shape of the solution

There are never 511 separate moves to remember — only three stages:

  1. Moves 1 to 255: build a tower of 8 disks on B.
  2. Move 256: disk 9 crosses to C — the only time it moves.
  3. Moves 257 to 511: rebuild the 8-disk tower on top of it.

Stages 1 and 3 are each the 8-disk solution, with two towers' names swapped.

Which disk moves when

Disk 1 makes half of all the moves — 256 of them, on every odd-numbered move. Each larger disk moves half as often as the one above it, which is the binary counter hiding inside the puzzle: the disk that moves is one more than the number of times you can halve the move number and still get a whole number. Move 6 halves once, to 3, so move 6 is disk 2. There is more on that in Tower of Hanoi and binary.

DiskMovesFirst moves onThen every
1256move 12 moves
2128move 24 moves
364move 48 moves
432move 816 moves
516move 1632 moves
68move 3264 moves
74move 64128 moves
82move 128256 moves
91move 256

The smallest disk's circuit

With 9 disks — an odd number — disk 1 travels A → C → B → A for the whole game, never reversing. Every move in between is the only legal move that leaves disk 1 alone. Those two rules alone reproduce the list above move for move; the iterative solution explains why, and strategies turns it into something to play by.

About the 9-disk puzzle

Nine disks can be arranged on three towers in 19,683 different ways — 3⁹, because each disk can sit on any tower and the order on a tower is forced by the rule. Every one of those arrangements is a legal position you could reach. The perfect game passes through just 512 of them, the start and the finish included: about 2.6%.

That is what makes nine disks feel different from the small sizes. At three disks, the 8 positions on the shortest path are nearly a third of everything possible, and a wrong move lands somewhere familiar. At nine, a single slip puts you among the 97% of positions the solution never visits, and finding the way back by eye is genuinely hard. The solver exists for exactly that moment: tell it where the disks are and it finds the shortest route home from any of the 19,683.

Nine is odd, so disk 1 goes to C first. The 511 moves factor as 7 × 73; the game is Expert on this board and runs about eight and a half minutes at a move a second.

Other sizes

Frequently asked questions

How many moves does it take to solve Tower of Hanoi with 9 disks?

511 moves is the minimum: 2⁹ − 1 = 511. No solution with fewer moves exists, and any solution with more has wasted some.

What is the first move in 9-disk Tower of Hanoi?

Move disk 1, the smallest, from tower A to tower C. With an odd number of disks the smallest disk travels A → C → B → A for the whole game, so its first stop is C. Sending it to B first still lets you finish, but it costs one extra move.

How long does 9-disk Tower of Hanoi take to solve?

A perfect game is 511 moves, which at one move a second is 8 minutes and at three moves a second — about as fast as anyone plays by hand — 2 minutes.

How many positions are there in 9-disk Tower of Hanoi?

19,683, which is 3⁹. Each of the nine disks can be on any of the three towers, and once you know which disks share a tower their order is forced, so every one of those arrangements is a legal position. The shortest solution passes through only 512 of them.