🗼Tower of Hanoi
Play Tower of Hanoi online free — the web version, no download needed. Choose 3–10 discs with animated move demos, undo/redo, hints and a one-click optimal solution walkthrough.
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
Tower of Hanoi is a classic recursive puzzle invented by French mathematician Édouard Lucas in 1883: move the whole stack from the start peg to the target peg, one top disc at a time, never placing a larger disc on a smaller one. The minimum number of moves for n discs is 2ⁿ−1 — 7 moves for 3 discs, 31 for 5, 255 for 8, and 1023 for 10.
Pick your difficulty
Use the number buttons to choose 3-10 discs. Beginners should start with 3-4 discs; experienced players can jump straight to 6+.
Move recursively
Shift the top n−1 discs to the spare peg, move the largest disc to the target, then stack the n−1 back on top — plan every move this way.
Use undo and hints
Press Z to undo, Y to redo, and H to highlight the current optimal move whenever you get stuck.
Learn from the demo
Press D (or tap "Show Solution") to watch the optimal solution play out from your current position — great for teaching recursion.
Chase perfect runs
Finish in exactly 2ⁿ−1 moves. Best move counts and times per disc count are saved locally so you can keep beating your records.
Tips for Best Results
Parity sets your opening
With an odd number of discs, move the smallest disc to the target peg first; with an even stack, move it to the spare peg first — the rest then follows one optimal path.
Think biggest-first
Decide early when the largest disc can move, and clear its target peg in advance; the whole solve then falls into place.
Rotate the smallest disc
The smallest disc moves every other turn, always circling in the same direction — a classic mantra for staying on the optimal route.
FAQ
What are the rules of Tower of Hanoi?
Move the entire stack from the first peg to the third peg. You may only move the top disc of one peg at a time, and a larger disc may never sit on a smaller one. The minimum for n discs is 2ⁿ−1 moves.
How many moves does 8-disc Tower of Hanoi take?
8 discs need 255 moves (2ⁿ−1). 10 discs need 1023. This page supports 3–10 discs with undo and hints to approach the optimal path.
Is there a trick or strategy?
Think recursively: move the top n−1 discs to the spare peg, move the biggest disc, then repeat. For an odd stack start the smallest disc toward the target; for an even stack toward the spare.
Can I play free without downloading?
Yes. This Tower of Hanoi game is completely free, needs no download or install, runs right in your browser, and works with both touch screens and keyboards.
What age is Tower of Hanoi good for?
Around age 6 and up. Three or four discs teach rules and sequencing to younger kids, while five or more discs build recursive planning skills often used in programming education.
Can I undo a wrong move?
Yes — every move can be undone (Z) and redone (Y). You can also press H for the optimal-move hint or D to auto-play the full solution.
What is the spare peg in Tower of Hanoi?
The spare peg (also called the auxiliary peg) is where discs rest temporarily while moving the stack. The 2ⁿ−1 minimum-move recursion depends on it: shift the top n−1 discs to the spare peg so the largest disc can reach the target, then bring the n−1 back over. Large discs can only swap positions by way of the spare peg.
More Games
- FreeCellPlay FreeCell online free — no download, no install. Works with classic Windows deal numbers 1–32000, plus unlimited undo, double-tap auto-home and safe auto-play.
- Whack-a-Mole OnlineFree online whack-a-mole — no download. Easy/Normal/Hard, golden & swift moles, avoid bombs, combo multipliers
- Reaction TestClick when the red turns green: 5-round reaction time test with average score, personal best, shareable results, touch & spacebar ready
- Bounce BallA JezzBall-style arcade: slide to seal walls around bouncing balls, fill 75% to clear, higher levels add faster balls
More in this series
- Slide PuzzleClassic 15-puzzle — slide tiles to restore order 1–15
- SokobanThe warehouse-keeper classic — push every crate onto a goal spot
- TangramThe classic Chinese tangram: fit all seven pieces back into the square silhouette with rotation, flipping and grid snapping
- KlotskiPlay classic Klotski online: slide wooden blocks to free Cao Cao through the bottom exit, free browser puzzle with move hints and undo