Tower of Hanoi: Online Puzzle With Solver
This Tower of Hanoi game lets you play the classic disk puzzle free online. Move the whole stack of disks to another peg, one disk at a time, never placing a larger disk on a smaller one. Pick from 3 to 8 disks, count your moves and watch the solver show the fewest-move answer.
Tower of Hanoi
Move the whole tower to the right peg in the fewest moves.
How to use the Tower of Hanoi
- Choose the number of disks.
- Click a peg to pick up its top disk, then click another peg to drop it.
- Never put a bigger disk on a smaller one.
- Get all disks onto the right peg to win.
- Press Auto-solve to watch the shortest solution.
Features
- 3 to 8 disks
- Click or tap to move, with illegal moves blocked
- Move counter versus the minimum 2ⁿ − 1
- Animated auto-solver with speed control
- Best scores saved
Frequently asked questions
What is the minimum number of moves?
2ⁿ − 1 moves for n disks: 7 for 3 disks, 15 for 4, 31 for 5 and 63 for 6.
What is the trick to solving it?
Move the smallest disk every other move, always in the same direction, and make the only other legal move in between.
Why is it used to teach recursion?
To move n disks you move n − 1 disks out of the way, move the biggest disk, then move the n − 1 disks back on top, which is a recursive solution.
Can I use the middle peg as the goal?
The goal here is the right peg, but the puzzle works the same either way.
See also: Sliding Puzzle, Water Sort Puzzle, Memory Game, Sudoku Online.
How to solve Tower of Hanoi
How to use it
- Pick the number of disks.
- Click a peg to pick up its top disk, then click another peg to drop it.
- Never put a bigger disk on a smaller one.
- Move the whole stack to another peg to win.
More questions
What is the fewest number of moves?
2ⁿ − 1, where n is the number of disks. Three disks take 7 moves.
Is there a trick to solving it?
Move the smallest disk every other turn, always in the same direction, and make the only other legal move between.
Is Tower of Hanoi good for kids?
Yes. It builds planning and patience, and it starts easy with 3 disks.
Related tools: Sliding Puzzle, Lights Out Puzzle, Maze Game.