Toolstia / Tower of Hanoi game

Tower of Hanoi game

Move a stack of disks from the left peg to the right peg. Only one disk can move at a time, and a bigger disk can never sit on a smaller one. Choose between 3 and 8 disks and try to match the fewest possible moves.

0Moves
15Fewest possible

Click a peg to pick up its top disk.

Move the whole stack to the right-hand peg. Only one disk moves at a time, and a bigger disk may never sit on a smaller one. The fewest moves for n disks is 2 to the power n, minus 1.

How it works

  1. Choose the number of disks.
  2. Click a peg to pick up its top disk, then click the peg to put it on.
  3. Move the whole stack to the right-hand peg.

The rules

You have three pegs. All disks start on the first one, biggest at the bottom. You win when the whole stack is on the last peg.

Fewest moves

A tower of n disks needs 2 to the power n, minus 1 moves. That is 7 for 3 disks and 255 for 8.

Strategy

To move n disks, move the top n-1 to the spare peg, move the biggest to the target, then move the n-1 on top of it. For an odd number of disks, the smallest disk goes to the target peg first.

Undo

Use Undo to take back your last move.

Questions

Can the puzzle be solved with any number of disks?

Yes, always. It just takes more moves each time you add a disk. Everything happens in your browser, and nothing you enter is sent anywhere.

What if I pick the wrong peg?

Click the same peg again to put the disk back, or use Undo after a move.

Is there a hint?

There is no hint button, but the strategy section describes the pattern.