Tower of Hanoi is a free brain puzzle where you move a stack of discs from one peg to another. Choose from 3 to 8 discs. It runs in your browser with no download or sign up, works on phones and computers and keeps working offline once loaded.
Inspired by: The Tower of Hanoi puzzle by Edouard Lucas (1883).
How to play Tower of Hanoi
- Pick how many discs you want, from 3 to 8.
- Click or tap a peg to lift its top disc, then click the peg where it should go. You can also drag a disc.
- Move one disc at a time and never put a bigger disc on top of a smaller one.
- Move the whole tower to another peg. The counter shows your moves and the fewest possible moves.
- Finish in the fewest moves and a fast time for the best score.
Controls
- Keyboard: Press 1, 2 or 3 to pick a peg. Or use Left and Right and Space. X puts a lifted disc back.
- Mouse: Click a peg to lift a disc and click another peg to drop it. Dragging works too.
- Touch screen: Tap a peg to lift its top disc, then tap where it goes, or drag it.
Tips to score higher
- With an even number of discs, the smallest disc moves to the middle peg first. With an odd number it moves to the far peg.
- Move the smallest disc every second turn and always in the same direction around the pegs.
- The best number of moves is always 2 to the power of the discs, minus 1.
- To move a tower of n discs, first move the top n minus 1 discs away.
- Start with 3 discs, find the rhythm, then step up.
The story behind Tower of Hanoi
The Tower of Hanoi was invented by the French mathematician Edouard Lucas in 1883 and sold as a toy. The story that came with it told of monks moving 64 golden discs, with the world ending when they finished. The puzzle is a favourite of maths teachers because it shows recursion so clearly. Moving n discs takes at least 2 to the power n, minus 1 moves, so 64 discs would take far longer than anyone could play. Many Indian students first meet it in a computer class or a school maths lab, and then never forget it.
Questions players ask
Is this Tower of Hanoi free?
Yes. It is free with no sign up and no download.
How many discs can I play with?
You can choose from 3 to 8 discs. More discs make a longer puzzle.
What is the minimum number of moves?
It is 2 to the power of the number of discs, minus 1. For 3 discs that is 7, and for 8 discs it is 255.
Can I cheat and put a big disc on a small one?
No. The game blocks that move and shakes the peg to remind you of the rule.
Does it work on mobile?
Yes. Tap a peg to lift a disc and tap again to drop it.