Home › Games › Tower of Hanoi

Tower of Hanoi

~2 min per roundClassicFree, no sign-up

Move the whole tower from peg A to peg C, one disc at a time, never placing a larger disc on a smaller one.

0Moves
15Minimum
–Record

Tap a peg to pick up the top disc, then tap the destination peg.

Rules

How to play Tower of Hanoi

  1. All the discs start stacked on peg A, from largest (bottom) to smallest (top).
  2. On each move, you take the top disc from one peg and place it on another.
  3. A disc can never sit on top of a smaller disc.
  4. The goal is to rebuild the whole tower on peg C.
  5. The minimum number of moves is 2ⁿ − 1: 7 with 3 discs, 15 with 4, 31 with 5, 63 with 6 and 127 with 7.

Controls

Tap the source peg (the top disc lifts) and then the destination peg. With the keyboard, keys 1, 2 and 3 choose pegs A, B and C, or use Tab and Enter.

Tips

To do better

  • With an odd number of discs, move the smallest one to peg C first; with an even number, to peg B.
  • The smallest disc moves every second move, always cycling in the same direction.
  • Between one move of the smallest disc and the next, there is only one valid move with the other discs.
  • To move a tower of n discs, first move the tower of n − 1 discs to the spare peg.

Your data: this game runs entirely in your browser. Nothing from your game is sent to us. Records are only stored, on your device, if you allow it in .

Frequently asked questions

Questions about Tower of Hanoi

Where does this puzzle come from?

The Tower of Hanoi was introduced by the French mathematician Édouard Lucas in 1883 and became a classic of maths and programming classes.

Why is the minimum 2ⁿ − 1?

To move n discs, you have to move n − 1 discs aside, move the largest, and then bring the n − 1 back on top. That doubles the work with every extra disc, plus one move.

Does the record apply to each number of discs?

Yes. We keep the lowest number of moves for each number of discs, if you allow saved progress.

Does it involve money or prizes?

No. It is a free puzzle with no prizes.

Other games