Mini Game · Logic · Recursion

Tower of Hanoi

Move all disks from peg A to peg C using the fewest moves possible. A larger disk can never sit on top of a smaller one.

🎉

Puzzle Solved!

You did it in 0 moves.
Minimum possible: 0.

Moves 0
Minimum 7
Disks 3
Time 0:00

How to Play

  • 🖱️ Click a peg to pick up the top disk, then click another peg to place it.
  • You cannot place a larger disk on a smaller one.
  • 🏆 Move all disks from Peg A to Peg C to win.
  • ↩️ Use Undo to take back your last move.
  • 🤖 Auto-Solve watches the optimal solution play out.

The Math

The minimum number of moves to solve n disks is:

2ⁿ − 1

3 disks → 7 moves  |  5 disks → 31 moves  |  8 disks → 255 moves

Move Log

No moves yet…

CS Connection

Tower of Hanoi is a classic example of recursion — the problem of moving n disks reduces to moving n−1 disks twice with one base move. It demonstrates O(2ⁿ) exponential time complexity.