The rules
- Move one disc at a time.
- Only the top disc of a stack can move.
- Never put a disc on top of a smaller disc.
Minimum number of moves
With three pegs, a tower of n discs needs at least 2n − 1 moves.
| Discs | Fewest moves (3 pegs) | Fewest moves (4 pegs) |
|---|---|---|
| 3 | 7 | 5 |
| 4 | 15 | 9 |
| 5 | 31 | 13 |
| 6 | 63 | 17 |
| 7 | 127 | 25 |
| 8 | 255 | 33 |
| 9 | 511 | 41 |
Each extra disc doubles the work and adds one. The legend says monks moving 64 golden discs would need 264 − 1 moves: at one move a second, about 585 billion years.
The easy method (works for any size)
- Move the smallest disc every other turn, always the same way round. With an even number of discs, go A → B → C → A. With an odd number, go A → C → B → A.
- On the turns in between, make the only other legal move that doesn't use the smallest disc. There is always exactly one.
- Repeat until the tower is rebuilt. This always finishes in the minimum number of moves.
Why it works (the recursive idea)
To move 5 discs from A to C: first move the top 4 out of the way to B, then move the big disc to C, then move the 4 from B onto it. Moving 4 discs works the same way with 3, and so on. That is why the moves double with every disc.
Solving 3 discs, move by move
Discs are 1 (small), 2 and 3 (big), all on peg A. Goal: peg C.
- 1 to C
- 2 to B
- 1 to B
- 3 to C
- 1 to A
- 2 to C
- 1 to C
The puzzles in our game
- Tower Road: 5 worlds of 10 levels. Every par is the exact minimum, checked by computer, and 3 stars means you matched it.
- Four Winds adds a fourth peg (the numbers in the right column above). Mirror Hall asks you to rebuild a target picture.
- Narrow Bridge only lets a disc step to the next peg, and Spiral Wind only lets discs move clockwise. Both need far more moves.
- A live counter shows "on par" or how many moves over you are, so you know if you went wrong.
Common questions
What is the minimum number of moves for the Tower of Hanoi?
2^n − 1 for n discs on three pegs: 7 for 3 discs, 15 for 4, 31 for 5, 63 for 6.
What is the trick to the Tower of Hanoi?
Move the smallest disc every other move, always in the same direction round the pegs, and make the only other legal move in between.
How many moves for Tower of Hanoi with 4 pegs?
Far fewer: 5 for 3 discs, 9 for 4, 13 for 5, 17 for 6, 25 for 7 and 33 for 8.
Is the Tower of Hanoi good for your brain?
It is a classic planning puzzle used to teach recursion and to test problem solving, and a fun one to practise.