Tower of Hanoi online
Move every disk from peg A to peg C. Move one disk at a time and never put a larger disk on a smaller one. Pick 3 to 8 disks and try to reach the fewest moves.
What is the Tower of Hanoi?
The Tower of Hanoi is a puzzle with three pegs and a stack of disks of different sizes. The goal is to move the whole stack to another peg, one disk at a time, without ever placing a larger disk on a smaller one. With n disks, the shortest solution takes 2 to the power of n, minus 1 moves.
How to play
- The game has three pegs: A, B and C. All disks start on peg A, from the largest (bottom) to the smallest (top).
- The goal is to move the whole tower to peg C, in the same order.
- Move one disk at a time. Only the top disk of a peg can leave.
- A disk never sits on a smaller disk. It can go to an empty peg or on top of a larger disk.
- Tap the peg the disk leaves and then the peg it goes to. You can also drag the disk.
- On a computer, keys 1, 2 and 3 (or A, B and C) pick the pegs. The Z key undoes a move.
- Made a mistake? Tap Undo move. You can go back as many moves as you want.
- Want to see how it is done? Tap Show solution. The game solves the tower step by step, from where you stopped.
- You win when every disk is on peg C. The game shows your moves and the fewest possible.
Levels and options
- 3 disks: at least 7 moves. The best size to learn the rule.
- 4 disks: at least 15 moves.
- 5 disks: at least 31 moves.
- 6 disks: at least 63 moves.
- 7 disks: at least 127 moves.
- 8 disks: at least 255 moves. The biggest challenge here.
- Each disk has a color, a width and a number. Disk 1 is the smallest.
- The game is relaxed: no clock runs against you. Turn on Show the time if you want to time yourself.
- The tower in progress and your records stay saved on your device.
Tips to play better: how to solve the Tower of Hanoi
- Think backwards. For the largest disk to reach peg C, all the others must be stacked on peg B. That is the secret of the game.
- The recipe works for any size: move the smaller tower (every disk except the largest) to the spare peg, move the largest disk to the goal, then move the smaller tower on top of it.
- Disk 1 moves every other turn. It always travels around in the same direction. With an odd number of disks: A, C, B, A. With an even number: A, B, C, A.
- Between two moves of disk 1, there is only one allowed move with the other disks. Make that move.
- First move: with an odd number of disks, disk 1 goes to peg C. With an even number, it goes to peg B.
- In the shortest solution, an even disk never sits on another even disk, and an odd disk never sits on another odd disk. Use this to check your path.
- Start with 3 disks and add one at a time. Each extra disk doubles the work and adds one: 7, 15, 31, 63, 127, 255.
Who this game is for
The Tower of Hanoi is a classic logic puzzle. It exercises planning and attention, with no hurry and no reading. Children learn the rule with 3 disks. Adults and seniors find plenty of challenge with 6, 7 or 8 disks.
Teachers use the game to show sequences, patterns and powers of 2. The disks are large, numbered and easy to tap on a phone.
Frequently asked questions
What is the minimum number of moves in the Tower of Hanoi?
With n disks, the minimum is 2 to the power of n, minus 1. That is 7 moves with 3 disks, 15 with 4, 31 with 5, 63 with 6, 127 with 7 and 255 with 8.
How do you solve the Tower of Hanoi?
Move disk 1 every other turn, always around in the same direction. On the turn in between, make the only allowed move with the other disks. Repeat until the tower stands on peg C.
What are the rules of the Tower of Hanoi?
Move one disk at a time, always the top disk of a peg. Never put a larger disk on a smaller one. The game ends when the whole tower stands on another peg.
Who invented the Tower of Hanoi?
The French mathematician Édouard Lucas presented the puzzle in the 19th century. It came with the legend of a temple where monks move 64 golden disks.
Is my game saved if I close the page?
Yes. The tower in progress and your records are saved only on your device. Nothing is sent to the internet.
See also

Peg Solitaire
Jump the pegs until one is left. Even better in the center.

Sliding Puzzle
Slide the tiles and put the numbers in order. 15 puzzle.

Sudoku
Fill the grid from 1 to 9 with no repeats. Daily puzzle.

Minesweeper
Open every safe square without touching a mine.

Chess
Full chess against the computer or a friend.