🗼Tower of Hanoi
Classic Tower of Hanoi puzzle with 3-8 discs — animated moves, undo/redo, hints and a one-click optimal solution demo
Move all discs onto the rightmost peg in order — never place a bigger disc on a smaller one! · Tap a peg to pick up/drop a disc (or keys 1/2/3, ←→ + Enter); Z undo, Y redo, H hint, D auto-solve, R restart.
How to Use
Move the whole stack from peg 1 to peg 3 to win. Rules: only the top disc of a peg can move, and a larger disc can never be placed on a smaller one. The minimum for n discs is 2ⁿ−1 moves — try to match it! Includes undo/redo, an optimal-move hint, and a one-click animated walkthrough of the full solution (great for teaching). Your best result for each disc count is saved locally.
FAQ
Is there a strategy for Tower of Hanoi?
Think recursively: to move n discs, move the top n−1 to the spare peg, move the largest disc to the target, then bring the n−1 discs over. With an odd disc count, move the smallest disc to the target peg first; with an even count, to the spare peg. Press H when stuck.
How many moves does it take at minimum?
The minimum is 2ⁿ−1 moves: 7 for 3 discs, 15 for 4, 31 for 5, and 255 for 8 discs.
Can the game show me the solution?
Yes. Tap “Show Solution” or press D to auto-play the optimal solution from the current position. Tap any peg during the demo to stop and take over — perfect for classroom demos.
Can I undo a wrong move?
Yes. Every move can be undone (Z) and redone (Y), so you can always rewind before starting over.