Tower of Hanoi

Move all discs from one peg to another, one at a time, without ever placing a larger disc on a smaller one.

Tower of Hanoi

Move all discs from the first peg to the last peg.

Moves
0 / 7
Time
00:00
Best: - moves (3 discs)
A B C

Puzzle Complete!

moves in
Optimal: moves
Click a peg to pick up its top disc, then click another peg to place it.

Features

  • Classic Tower of Hanoi puzzle with 3 pegs
  • Selectable disc count from 3 to 8
  • Move counter showing current moves vs optimal (2^n - 1)
  • Timer for speed-running challenges
  • Star rating system: 3 stars for optimal solution, 2 for within 1.5x, 1 for completion
  • Auto-solve visualization using the classic recursive algorithm
  • Undo button to take back the last move
  • Color-coded discs with gradient palette
  • Invalid move detection with shake animation
  • Win celebration overlay with stats
  • Best moves tracking per disc count (saved locally)
  • Touch-friendly controls for mobile devices
  • Responsive design that scales across screen sizes

How to Use

  1. Select the number of discs (3-8) using the dropdown.
  2. Click a peg to pick up its top disc (it will lift and glow).
  3. Click another peg to place the disc there. You cannot place a larger disc on a smaller one.
  4. Move all discs from peg A to peg C to win.
  5. Try to solve the puzzle in the optimal number of moves (2^n - 1) for 3 stars.
  6. Use the Undo button to take back your last move.
  7. Press Auto-Solve to watch the recursive algorithm solve it step by step.