🗼 Tower of Hanoi
🧩 Logic · 0 playsTower of Hanoi
Rebuild the stack on another peg, with no disc ever covering one smaller than itself.
About Tower of Hanoi
Édouard Lucas published this in 1883, and it has served ever since as the standard illustration of recursion. The whole tower must be reassembled on a different peg, one disc moved per turn, and no disc ever allowed to cover something smaller than itself. The shortest solution takes two to the power of the disc count, less one: seven moves for three discs, 255 for eight. The puzzle stops being difficult the moment you see that shifting n discs means first shifting n-1 of them out of the way — after which the whole thing unrolls almost automatically.
How to Play
Tap a peg to lift its top disc, then tap another peg to set it down. No disc may come to rest on top of a smaller one. Rebuild the complete tower on the right-hand peg, and try to match the minimum move count.
💡 Tips & Strategy
The puzzle has a rhythm rather than a trick. To move a stack of n discs you first move the top n minus 1 out of the way onto the spare peg, move the largest disc across, then bring the smaller stack back on top. Every optimal solution is that same idea nested inside itself.
There is a mechanical version that needs no recursion at all. The smallest disc moves on every other turn, always in the same direction — for an odd-sized stack it cycles one way around the three pegs, for an even stack the other. On the turns in between, exactly one legal move exists that does not involve the smallest disc, so play it.
The minimum is 2 to the power n minus 1 moves: 7 for three discs, 31 for five, 1023 for ten. If your count is drifting above that, you are almost certainly shuffling the smallest disc back and forth instead of alternating.
Never undo your previous move. Since only one non-smallest move is ever legal, an undo is always a wasted pair of turns, and avoiding it alone keeps most players close to optimal.