Brain Games IQ · Recursion Classic
Tower of Hanoi
Move the whole stack to the last peg, one disk at a time — and never put a bigger disk on a smaller one.
Keyboard: 123 pegs · U undo · H hint · S auto-solve · R restart · Esc stop demo
Like this? Try Number Grid Sums or Target Number.
📖How to Play
- 🎯Goal: All disks start on the left peg, smallest on top. Move the whole stack to the right peg marked Goal.
- 📏Rules: One disk at a time, always the top disk, never a bigger disk onto a smaller one.
- 👆Move: Tap a peg to lift its top disk, tap another peg to drop it. Keyboard: 1 / 2 / 3 pick pegs, U undo, H hint, S auto-solve, Esc stop the demo.
- 💡Hint: Glows the source peg gold and the destination green for the next optimal move from your current position. A run that uses any hint is marked “solved with hints” and does not earn a tier or count toward your best scores.
- ▶️Auto-solve: Always available in the toolbar (and on the start screen). Watches the full optimal recursion at your chosen speed. It’s a demo — it never counts toward your best scores. Stop anytime with the same button or Esc.
- ↶Undo: Takes back your last move but still counts as a move.
- 🏅Targets: Gold = minimum moves (2n − 1), Silver ≤ 1.5×, Bronze ≤ 2×. The Target box shows your next tier.
🗼About the Tower of Hanoi
The minimum number of moves for n disks is 2n − 1: 3 disks need 7, 5 need 31, 7 need 127. Each extra disk roughly doubles the work — a favorite example in computer science and psychology.
Think recursively: move the top n − 1 disks to the spare peg, move the biggest disk to the goal, then move the n − 1 back on top. Odd and even disk counts start the smallest disk on different pegs — watch the auto-solve for both and spot the pattern.
| Disks | 🥇 Gold (2ⁿ−1) | 🥈 Silver ≤ | 🥉 Bronze ≤ |
|---|---|---|---|
| 3 | 7 | 10 | 14 |
| 4 | 15 | 22 | 30 |
| 5 | 31 | 46 | 62 |
| 6 | 63 | 94 | 126 |
| 7 | 127 | 190 | 254 |
Shift the tower above. Move the top n − 1 disks onto the spare peg — that’s the same puzzle, one size smaller.
Free the giant. Move the biggest disk straight to the goal peg. It never moves again.
Rebuild on top. Move the n − 1 disks back onto the biggest disk. Recursion does the rest.
🔒 Built for fun practice, not assessment. Best results are saved only in this browser.