Tower of Hanoi Online: Play 3 to 10 Discs, with a Step-by-Step Solver

The Tower of Hanoi is a famous puzzle about patience and planning. Move the whole stack of discs from the first peg to the last, one disc at a time, never putting a bigger disc on a smaller one. Three discs take 7 moves; ten take 1,023. Stuck halfway? The solver finishes from wherever you are, in the fewest possible moves.

loading tool

How to play the Tower of Hanoi

  1. Choose how many discs (start with 3 or 4).
  2. Tap a peg to lift its top disc, then tap another peg to drop it.
  3. Move the whole tower to peg 3, never placing a bigger disc on a smaller one.
  4. Press “Show me the solution” to watch the fewest moves from your current position.

Good to know

  • Keyboard: press 1, 2 or 3 to pick up and drop, or use the arrow keys and Enter.
  • The smallest disc moves on every other turn, always in the same direction around the pegs.

Questions

What is the fewest number of moves?

For n discs it is 2ⁿ − 1: 3 discs need 7, 4 need 15, 5 need 31, 8 need 255 and 10 need 1,023.

What is the trick?

To move a tower of n discs, first move the top n − 1 discs out of the way, move the biggest disc, then move the n − 1 discs back on top of it. The same idea repeats for every smaller tower.

Why is it used in schools?

It is a classic way to teach recursion in computing and powers of two in maths, and a good test of planning ahead.

Is my data private?

Yes. Everything happens inside your own browser: nothing you type or choose is uploaded to us or anyone else.

Is it free?

Completely free, with no sign-up, no watermark and no limit on how many times you use it. Light ads keep the site running.