Tower of Hanoi

About Tower of Hanoi

Tower of Hanoi is a famous mathematical puzzle. Discs of different sizes are stacked on the left peg, largest at the bottom. Your task is to move the entire tower to another peg, moving only one disc at a time and never placing a larger disc on top of a smaller one.

Pick from 3 to 8 discs. Three discs can be solved in just 7 moves, while eight discs need at least 255 — the minimum is always 2ⁿ − 1. A move counter compares your play against that optimal number, a timer tracks your speed, and your best moves and time are saved for every disc count. Stuck? Press Show solution to watch the puzzle solve itself from your current position, and stop it whenever you want to take over.

The puzzle runs instantly in your browser on phones, tablets and computers with no download. Tap a peg and then a destination, or simply drag the top disc where you want it.

How to play

  • Tap a peg to lift its top disc, then tap another peg to drop it there.
  • Or drag the top disc straight onto another peg.
  • A larger disc can never be placed on a smaller one.
  • Move the whole tower to the middle or right peg to win; the minimum is 2ⁿ − 1 moves.
  • Keyboard: 1 / 2 / 3 pick pegs, Esc cancels. Show solution animates the answer.