🗼 Tower of Hanoi

Move the whole stack to the far peg — never a bigger disk on a smaller.

DISKS
MOVES 0OPTIMAL 15BEST —

How to play Tower of Hanoi

  1. Pick how many disks to play with and press New Game.
  2. Tap a peg to lift its top disk, then tap another peg to drop it.
  3. You can never place a larger disk on top of a smaller one.
  4. Rebuild the whole stack on the right-hand peg to win.

Controls

Controls for Tower of Hanoi
InputAction
Tap a pegLift its top disk, or drop the held disk
Ctrl+FEnter or leave full screen
Ctrl+P / Ctrl+SpacePause and resume

Tips & strategy

  • The minimum number of moves for n disks is 2ⁿ−1 — four disks takes 15.
  • To move a stack, first move everything above the bottom disk to the spare peg.
  • Alternate your smallest disk in a steady direction each turn for the optimal solution.
  • Start with three disks to learn the rhythm, then add more.

Frequently asked questions

What is the minimum number of moves?

For n disks the optimal solution takes 2ⁿ−1 moves: 7 for three disks, 15 for four, 31 for five, and so on.

Can every puzzle be solved?

Yes — Tower of Hanoi always has a solution, and the game shows the optimal count to aim for.

How is my score tracked?

Your record is the fewest moves you have used to solve each disk count.