Learn
How to Play Tower of Hanoi
Three rules, one goal. Read them, see them, then try them on a three-disk board right here on the page.
On this page
Tower of Hanoi is a puzzle of three towers and a stack of disks, each a different size. The French mathematician Édouard Lucas published it in 1883. It takes about a minute to learn, and this page is that minute.
Objective
You start with every disk stacked on the left tower, A, largest at the bottom and smallest on top. Your goal is to rebuild that exact stack on the right tower, C.
The middle tower, B, is not decoration — it is working space. Every game with more than one disk has to park disks there on the way.
Start. Every disk is on tower A, largest at the bottom. Only disk 1 is on top of its tower, so at this moment it is the only disk in the game that can move.
Goal. The same stack, in the same order, on tower C. Tower B is empty again — it was only ever working space.
- A, B, C
- The three towers, left to right. The letters are printed under the towers on the board, and every move list on this site uses them.
- Disk 1
- The smallest disk. Numbers grow with size, so on a five-disk board disk 5 is the largest one at the bottom.
- A → C
- One move: take the top disk off tower A and put it on tower C. Move lists often add the disk number too, as the one below does, but the two letters are enough on their own — only one disk on a tower can ever be the one that moves.
The Three Rules
- Move one disk at a time.
- Only the top disk of a tower can move. Disks buried under others are locked in place until they are uncovered.
- A larger disk may never rest on a smaller one. A disk can go onto an empty tower or onto a bigger disk, and nowhere else.
AllowedDisk 2 onto disk 3. The disk you are carrying is smaller than the one it lands on, so the stack stays in order. Dropping onto a completely empty tower is always allowed too.
Not allowedDisk 3 onto disk 1. The disk you are carrying is larger than the one it would land on. The board refuses the move, says why, and puts the disk back where it came from — nothing is lost.
That is the whole rulebook. There is no rule against moving the same disk twice in a row, no time limit and no limit on moves — you cannot lose. The only pressure is your own move count.
How to Move a Disk
A move is two actions: lift a disk, then drop it on another tower. The board gives you three ways to do that.
- Tap or click. Tap a tower to lift its top disk. The disk rises to show it is in your hand, and the towers it can legally go to light up. Tap the destination to drop it, or tap the same tower again to put the disk back.
- Drag. With a mouse or trackpad, press on a tower and drag the disk to another one; the tower under the pointer shows whether it will take the disk. On a phone, tap instead — a finger would cover the very disk it was dragging.
- Keyboard. Tab to the board, then press1, 2 or3 to lift from and drop on towers A, B and C. Or use the arrow keys: ←→ to choose a tower,↑ to lift and ↓ to drop. Esc puts the disk back.
If the destination holds a smaller disk, the move is refused: the tower flashes, the disk goes back to the tower it came from, and a short message says why. A refused move does not count.
Try It: Three Disks
This board plays by exactly the same rules as the real one. Try to break rule three — put a bigger disk on a smaller one — and see what happens. Then finish the game.
That is the whole game.Play Tower of Hanoi with more disks →
Example: the Three-Disk Game
Three disks take seven moves. Press play, or step through them one at a time; the table follows the board, and clicking a row jumps straight to that move. Disk 1 is the smallest, disk 3 the largest.
Three disks on tower A. Seven moves to go.Step 0 of 7
| Move | Disk | From | To |
|---|---|---|---|
| 1 | 1 | A | C |
| 2 | 2 | A | B |
| 3 | 1 | C | B |
| 4 | 3 | A | C |
| 5 | 1 | B | A |
| 6 | 2 | B | C |
| 7 | 1 | A | C |
How to Win
You win the moment every disk sits on tower C in the original order. The board counts your moves as you go, and saves your best result for each disk count in your browser.
- Hint only points at the next move — you still make it, so a hinted game can still set a best score.
- Step and Auto Solve make moves for you. The game still finishes, but it won't overwrite your best score.
Minimum Number of Moves
A perfect game of n disks takes 2ⁿ − 1 moves, and no solution is shorter. Every disk you add doubles the length of the game, plus one move.
| Disks | Minimum moves |
|---|---|
| 3 | 7 |
| 4 | 15 |
| 5 | 31 |
| 6 | 63 |
| 7 | 127 |
| 8 | 255 |
The board goes up to 15 disks, which is 32,767 moves. For any other size, up to the sixty-four disks of the original legend, use the minimum moves calculator.
Where to Go Next
- Play Tower of Hanoi — start at three disks, win once, then add one.
- Tower of Hanoi strategies — the one idea that solves every size, and the shortcut for knowing your next move.
- Tower of Hanoi solver — stuck halfway through a game? Tell it where your disks are and get every remaining move.
- Minimum moves calculator — the move count and the time it takes, for any number of disks.
- Teaching it — a 45-minute lesson plan with timings, a worksheet to print, and instructions for building a set out of cardboard.
Frequently Asked Questions
Why won't the board let me make a move?
Only two moves are refused. Tapping an empty tower first is refused, because there is no disk to pick up. Dropping a disk onto a smaller one is refused too, and the board puts the disk back where it came from. Either way the board says why, and neither counts as a move.
Do I have to use the middle tower?
Yes, in every game with more than one disk. The largest disk can only reach tower C once every smaller disk is off it and none of them is sitting on C — and the only place left for them is tower B. The middle tower is not a detour; it is where most of the game happens.
How many disks should I start with?
Three. That is seven moves, small enough to see the whole pattern at once. Set the disk count to three for your first game, then add one disk each time you win — every disk you add roughly doubles the length of the game.
Can I move a disk straight back to where it came from?
Yes. Nothing in the rules forbids it, and the board will let you. It costs two moves and leaves the board exactly as it was, though, so in a game you are trying to finish efficiently it is always a wasted pair.
Have I lost if I take more than the minimum number of moves?
No. You win the moment every disk is on tower C, however many moves it took. The minimum — 2ⁿ − 1, which is 7 for three disks — is a score to aim at, not a condition of winning.