Computer science · Algorithms

Tower of Hanoi: ten levels

From 1 to 10 disks: play, observe recursion and try to reach the minimum number of moves.

Read the article: rules, strategy and recursion

Move all disks from A to C. Tap a peg to select its top disk, then tap the destination peg. Move only one disk at a time and never put a larger disk on a smaller one. Keyboard: Tab to choose a peg, Enter or Space to activate it.

Moves made—

Minimum from the start—

Minimum still needed—

Manual record on this device—

Choose a source peg. The goal is to move the whole tower to C.

Manual game

Start and One step continue from your current position: a different choice does not require a restart. Pause lets the current move finish. Restart resets only the current game, not records.

Recent moves

  1. No moves yet.

The last 12 moves are shown; Undo lets you return all the way to the start of the game.

Levels completed manually

Manual records are saved only in this browser, when available. No account or score submission. All levels are already selectable.

Why is the minimum 2ⁿ − 1?

To move n disks from A to C, first free the largest disk by moving the n−1 disks above it to B. Then move disk n from A to C. Finally move the n−1 disks from B to C.

  1. Move n−1 disks from A to B, using C as the auxiliary peg.
  2. Move disk n from A to C.
  3. Move n−1 disks from B to C, using A as the auxiliary peg.

M(0) = 0
M(n) = 2 × M(n−1) + 1 = 2n − 1

The same problem reappears with one fewer disk: this is recursion. With zero disks, do nothing. Each added disk doubles the previous minimum and adds one move. Hints and the guided solution use the same recursive strategy, adapted to the current position.

DisksMinimum moves
11
23
37
415
531
663
7127
8255
9511
101023

Further reading: Princeton, recursion and the Tower of Hanoi