← Back to Arcade

šŸ—¼ Tower of Hanoi

Move all disks to the rightmost peg — but never place a larger disk on a smaller one!

Moves
0
Optimal
7
Time
0:00
Best
—
Disks:

šŸŽ‰ Solved!

0
Moves
0:00
Time
7
Optimal

Well done!

šŸ“– How to Play

Goal

Move all the disks from the left peg to the right peg.

Rules

  • Only one disk may be moved at a time.
  • A disk can only be placed on an empty peg or on top of a larger disk.
  • You can never place a larger disk on top of a smaller one.

Controls

  • Click / Tap a peg to pick up its top disk, then click another peg to drop it.
  • Keyboard: Press 1, 2, or 3 to select source peg, then press again for destination.
  • Undo to take back your last move. Reset to start over.
  • Auto-Solve watches the computer solve it with the optimal recursive algorithm!

Tips

  • The minimum number of moves for n disks is 2ⁿ āˆ’ 1. For 5 disks that's 31 moves.
  • Try to match the optimal count for a Perfect Solution badge!
  • The recursive strategy: to move n disks from A to C, first move nāˆ’1 disks from A to B, then move the largest disk from A to C, then move nāˆ’1 disks from B to C.