Tower of Hanoi: 3, 4 and 5 Disk Solutions, Move by Move
Tower of Hanoi guide ยท 4 min read
Sometimes you just want the answer: the exact list of moves. This guide gives complete, move-by-move Tower of Hanoi solutions for 3 disks, 4 disks, and 5 disks, plus the simple pattern that links them so you never have to memorize anything. We'll label the pegs A (start), B (spare), and C (goal), and number the disks 1 (smallest) up to the largest. If you want to understand why these moves work rather than just copy them, read how to solve the Tower of Hanoi first.
The 3-disk solution (7 moves)
The easy 3-disk puzzle solves in 7 moves, the minimum:
- Disk 1: A โ C
- Disk 2: A โ B
- Disk 1: C โ B
- Disk 3: A โ C
- Disk 1: B โ A
- Disk 2: B โ C
- Disk 1: A โ C
After move 7, all three disks are stacked on peg C. Moves 1 to 3 clear the small disks onto the spare peg, move 4 sends the biggest disk home, and moves 5 to 7 rebuild the small stack on top.
The 4-disk solution (15 moves)
The medium 4-disk puzzle takes 15 moves. Watch how it contains the 3-disk solution inside it:
- Disk 1: A โ B
- Disk 2: A โ C
- Disk 1: B โ C
- Disk 3: A โ B
- Disk 1: C โ A
- Disk 2: C โ B
- Disk 1: A โ B
- Disk 4: A โ C
- Disk 1: B โ C
- Disk 2: B โ A
- Disk 1: C โ A
- Disk 3: B โ C
- Disk 1: A โ B
- Disk 2: A โ C
- Disk 1: B โ C
Moves 1 to 7 move the top three disks onto peg B (the spare). Move 8 sends the biggest disk, disk 4, straight to C. Moves 9 to 15 move those three disks from B onto C. Each of those seven-move halves is just a 3-disk solve in disguise, with the pegs relabeled.
The 5-disk solution (31 moves)
The hard 5-disk puzzle needs 31 moves. Rather than memorize a long list, use the structure: a 5-disk solve is two 4-disk solves wrapped around one move of the biggest disk.
- Moves 1 to 15: move the top 4 disks from A to B (this is exactly the 15-move 4-disk solution above, with C as the spare instead of B).
- Move 16: Disk 5: A โ C (the biggest disk reaches the goal).
- Moves 17 to 31: move the 4 disks from B to C (the 4-disk solution again, this time from B to C using A as the spare).
If you want the opening moves spelled out, the first few are: disk 1 AโC, disk 2 AโB, disk 1 CโB, disk 3 AโC, disk 1 BโA, disk 2 BโC, disk 1 AโC, disk 4 AโB, and so on. Notice this is the 3-disk pattern starting again. Every Tower of Hanoi solution is built from smaller ones nested inside it.
The pattern that connects them all
Look across the three solutions and the same rules appear every time:
- The smallest disk (disk 1) moves on every other move. Moves 1, 3, 5, 7 and so on are always the smallest disk.
- It always travels in the same direction. For an odd number of disks (3 or 5), disk 1 cycles A โ C โ B โ A. For an even number (4), it cycles A โ B โ C โ A.
- The moves in between are forced. On each even-numbered move there is only one legal move that doesn't involve the smallest disk, so you never have to choose.
That's the whole Tower of Hanoi trick: alternate the smallest disk with the only other legal move, and the optimal solution appears on its own.
Why the move counts double
You may have spotted the pattern in the totals: 7, 15, 31. Each is just over double the one before, because solving n disks means solving n โ 1 disks twice plus one move for the biggest disk. That gives the famous 2โฟ โ 1 formula, explained in full in the Tower of Hanoi formula. So 6 disks would be 63 moves, 7 disks 127, and so on up to the 10-disk Einstein level at 1,023.
Try it yourself
The fastest way to internalize these solutions is to play them. Open the 3-disk puzzle and follow the seven moves above, then do four disks and feel the 3-disk solution hiding inside it. Once you see that nesting, you can solve any size from memory of the pattern alone. The auto-solver on each level will replay the optimal moves whenever you want to check your work.