Towers of Hanoi is one of the oldest and best-known logic puzzles. A tower of disks, largest at the bottom, sits on the first of three pegs. Move the whole tower to the third peg, one disk at a time, without ever placing a larger disk on top of a smaller one.

Towers of Hanoi at the start: a stack of coloured disks on peg 1, with pegs 2 and 3 empty
Towers of Hanoi at the start: a stack of coloured disks on peg 1, with pegs 2 and 3 empty

The goal

Move every disk from peg 1 to peg 3. The puzzle completes automatically when the full tower is on peg 3.

Controls

  • Keyboard: press 1, 2 or 3 to choose a peg. Z undoes the last move. P pauses.
  • Touch: use the Peg 1, Peg 2, Peg 3 and Undo move buttons below the board.

A move takes two presses: first the peg to take a disk from, then the peg to put it on. The selected source peg turns pink. Pressing the same peg twice cancels the selection.

The rules

  • Only the top disk on a peg can move.
  • A disk can go onto an empty peg or onto a larger disk.
  • A disk can never go onto a smaller disk. If you try, the move is refused and nothing changes.

Undo takes back your last move, and you can undo as many moves as you like.

Your first round, step by step

With three disks on Chill, a perfect solution takes seven moves:

  1. Move the smallest disk from peg 1 to peg 3.
  2. Move the middle disk from peg 1 to peg 2.
  3. Move the smallest disk from peg 3 onto peg 2.
  4. Move the largest disk from peg 1 to peg 3.
  5. Move the smallest disk from peg 2 to peg 1.
  6. Move the middle disk from peg 2 onto peg 3.
  7. Move the smallest disk from peg 1 onto peg 3.

The same idea scales up: to move a tower, first move every disk except the largest onto the spare peg, then move the largest, then move the smaller tower back on top.

Scoring

A finished tower scores 2,000 points minus 10 for every move, with a minimum of 100. The fewest possible moves are 7 for three disks, 15 for four and 31 for five, so a perfect solve scores 1,920, 1,840 or 1,680. Refused moves do not count; undone moves do.

What changes from Chill to Expert

  • Chill: 3 disks (7 moves at best).
  • Standard: 4 disks (15 moves at best).
  • Expert: 5 disks (31 moves at best).

Standard gives five minutes to move every tower and Expert two minutes 30 seconds; reaching zero ends the run, and Chill is untimed.

Strategy tips

  • Where does the smallest disk go first? With an odd number of disks (3 or 5), move it to peg 3 first. With an even number (4), move it to peg 2 first.
  • Move the smallest disk every other turn. In a perfect solution, every second move is the smallest disk, always travelling round the pegs in the same direction.
  • The in-between move is forced. On the turns when you are not moving the smallest disk, there is only one legal move that does not involve it. Make that one.
  • Think in sub-towers. Before the largest disk can move, everything above it must be stacked on the spare peg.
  • Keep a rhythm on Expert. 31 moves in two and a half minutes is about one move every five seconds; the smallest-disk pattern keeps you quick.

Common mistakes

  • Moving the smallest disk to the wrong peg first and doubling the work.
  • Moving the smallest disk twice in a row.
  • Forgetting a move needs two presses, and moving the wrong disk by accident.
  • Trying to free the largest disk before the smaller disks are stacked on the spare peg.

Accessibility and sound

Towers of Hanoi makes no sound until ♪ is chosen, every move is captioned, and Text game status reads the pegs to a screen reader. The text status lists each peg's disks from bottom to top and the selected source peg, so the puzzle can be solved without seeing it. Disks also differ in width, not just colour.

Play it offline with Flight mode

The Tower of Hanoi travels well: online, press Flight mode · Save this game in the panel or Flight mode · Save game on its card, and it is stored for offline play. Cleared site data deletes your saved Towers of Hanoi, so re-save before you go.

Towers of Hanoi on Standard part way through, with disks spread across all three pegs
Towers of Hanoi on Standard part way through, with disks spread across all three pegs

Frequently asked questions

What is the fewest number of moves?

For a tower of n disks it is 2ⁿ − 1: 7 for three disks, 15 for four and 31 for five.

Can I put a disk on an empty peg?

Yes. Any disk can go onto an empty peg.

How do I cancel a selected peg?

Press the same peg again.

Ready to play?

Towers of Hanoi is free in your browser, with keyboard and touch controls and no account needed.

Play Towers of Hanoi

Quick rules and controls for Towers of Hanoi · More how-to-play articles