
How to Play Tower of Hanoi
The Tower of Hanoi rules fit in one sentence, yet the puzzle has fascinated people for well over a century and turns up in classrooms whenever recursion is taught. This page explains how to play the Tower of Hanoi on our site, why the minimum number of moves grows so fast, and a simple routine that solves any tower without guesswork.
Play nowThe goal
Move the entire stack of disks from the left peg to the right peg, which carries a little crown. The finished tower must be in the same order as the starting one: largest at the bottom, smallest on top.
The rules
That is all. The middle peg is free to use as a stopover, and so is the target peg before the tower is complete.
- Move one disk at a time.
- Only the top disk of a peg can be moved.
- A disk may never be placed on a smaller disk.
Setup on our site
The game has three levels, chosen in the New game dialog: Easy with 4 disks, Medium with 6 and Hard with 8. The tower always starts on the left peg. The bar shows Time, Moves and Minimum, the smallest number of moves the job can be done in.
How to move a disk
- Tap the peg whose top disk you want to move. The disk lifts.
- Tap the peg you want to put it on. If the move is legal, the disk drops there.
- If the target holds a smaller disk, the disk shakes and stays where it was. Choose another peg.
- On a keyboard, press Esc to cancel a lift.
- You can also drag a disk directly, or use the keys 1, 2 and 3 to select the pegs.
Minimum moves and scoring
Every tower of n disks needs at least 2ⁿ − 1 moves: 15 for four disks, 63 for six and 255 for eight. Each additional disk doubles the work and adds one. The game shows this number while you play and again on the Victory screen.
Your score depends on how close you come to the minimum, and it eases down slowly with time. Extra moves cost more than a slow pace, so accuracy is the first priority.
The recursive method
The classic Tower of Hanoi algorithm treats a big problem as two smaller copies of itself. To move a tower of n disks from the left peg to the right peg:
- Move the top n − 1 disks from the left peg to the middle peg, using the right peg as a helper.
- Move the largest disk from the left peg to the right peg.
- Move the n − 1 disks from the middle peg onto the right peg, using the left peg as a helper.
A routine you can play by hand
Recursion is elegant but hard to track in your head with eight disks. The same perfect solution can be played with a simple rhythm. Imagine the pegs in a circle. With an even number of disks, the smallest disk always steps left-peg, middle-peg, right-peg, and round again; with an odd number, it steps left, right, middle and round.
On every other move, move the smallest disk one step along its circle. On the moves in between, make the only legal move that does not involve the smallest disk. Follow that rhythm and you will finish in exactly the minimum.
Common mistakes
- Sending the smallest disk the wrong way at the start. Check whether the number of disks is even or odd first.
- Moving the smallest disk twice in a row. That always wastes moves.
- Building a temporary tower on the wrong peg, which forces the whole sub-tower to be moved again.
- Relying on undo to repair a long detour. Undo adds to the move count; the hint can show the shortest way back instead.
Glossary
- Peg: one of the three upright rods.
- Source peg: the left peg, where the tower begins.
- Target peg: the crowned right peg, where the tower must end.
- Spare peg: the middle peg used as a stopover.
- Minimum: the fewest possible moves, 2ⁿ − 1 for n disks.
- Recursion: solving a problem by solving smaller copies of the same problem.
FAQ
- What are the Tower of Hanoi game rules in short?
- Move one top disk at a time, and never place a larger disk on a smaller one. Get the whole tower to the crowned peg.
- Why does eight disks take so long?
- Because the minimum doubles with each disk. Eight disks need at least 255 moves, compared with 15 for four.
- Can I recover after a mistake?
- Yes. Keep playing, or watch a short video for a hint, which shows the best next move from wherever you are.
- Where can I try it?
- Open the Tower of Hanoi page and start with four disks. If you enjoy it, the Sliding Puzzle is another classic worth a go.
