Moves
0
Minimum
7
Time
0:00

Tower of Hanoi

Play the Tower of Hanoi online, then let the solver finish any position you get stuck in.

The rules

  • Move the whole tower from the first peg to the last.
  • Move one disk at a time, and only the top disk of a peg.
  • Never put a disk on top of a smaller one.

With n disks the fewest possible moves is 2ⁿ − 1: 7 for three disks, 1,023 for ten. Tip: with an odd number of disks, start by moving the smallest disk to the last peg; with an even number, to the middle peg.

How to play

Tap a peg to pick up its top disk, then tap the peg to put it on; you can also drag the disk. With a keyboard, press 1, 2 or 3 to choose a peg and Z to undo. Under the board you can choose anything from 3 to 10 disks, or a fourth peg.

Where to start

Whatever the size, the smallest disk moves every other move, and always round the pegs in the same direction. The moves in between are never a choice: only one other disk can legally move. So the puzzle is mostly about remembering which way the smallest disk is going, and the tip above gives you its first step. The How to Solve page shows why this works.

Your records

The board shows the fewest possible moves for the size you picked. Your best moves and time for each size are kept on this device only. There is no time limit: the clock is just a record.