Home

How to play Tower of Hanoi? Tower of Hanoi rules

Play Tower of Hanoi

Tower of Hanoi is a one-player logic puzzle played with rods and disks stacked from largest to smallest. A French mathematician brought it out as a toy in 1883; today it is the best-known example of recursion in computer science classes.

On this page we explain the rules of Tower of Hanoi on CetinsGame exactly as the game applies them. The site's Mind games collection also has other thinking games such as Reversi, Go, Hex, Dots and Boxes, Chess, Draughts and Mangala.

Rods and disks

The classic puzzle has 3 rods and a stack of disks on one rod, sorted from largest to smallest: the largest at the bottom, the smallest on top. The goal is to move all the disks, in the same order, to the target rod. In our game the target rod has a gold base and a small gold flag on top; it is not always the rightmost rod. There are 3 to 8 disks, and the last group uses 4 rods.

The three rules

  1. Each move moves one disk.
  2. Only the top disk of a rod can be taken; to reach a lower one, you first move the disks above it to other rods.
  3. A larger disk never goes on a smaller one. Any disk can go on an empty rod.

The game does not allow an illegal move: it shows a warning and does not add the attempt to your move count. To move a disk, tap its rod and then the rod where you want to drop it, or drag the disk; on a keyboard, the keys 1 to 4 select the rods from left to right.

Finishing a level and stars

A level ends when all the disks form a single tower on the target rod. Every level has an exactly known fewest number of moves, shown next to the counter.

  • Finish in the fewest moves: 3 stars.
  • Within 1.5 times the fewest moves: 2 stars.
  • More moves than that: 1 star.

There is no time limit. There is no undo either; if you go the wrong way, the Restart button resets the level to its starting layout with zero moves. The What would a master play? hint shows the best next move in two colours: move the top disk of the rod glowing gold to the rod glowing turquoise. A level where a hint was used gives at most 2 stars; Restart does not lift that limit.

Why 2ⁿ - 1 moves?

The largest disk can only move once all the disks above it are gathered on one other rod. So the shortest way to move n disks is:

  1. Move the top n - 1 disks to the third rod, using the target as a helper.
  2. Move the largest disk to the target (1 move).
  3. Move the n - 1 disks from the third rod onto the largest one.

Each new disk turns the move count into twice the old count plus one: 1 disk takes 1 move, 2 disks 3, 3 disks 7. So n disks need at least 2ⁿ - 1 moves.

Disks3 rods4 rods
375
4159
53113
66317
712725
825533

Step by step: 7 moves for 3 disks

Say the disks are on the left rod and the target is the right rod:

  1. Small disk from left to right.
  2. Middle disk from left to middle.
  3. Small disk from right to middle.
  4. Large disk from left to right.
  5. Small disk from middle to left.
  6. Middle disk from middle to right.
  7. Small disk from left to right.

The small disk moves on moves 1, 3, 5 and 7; in between there is only one legal move that does not touch it. If the number of disks is odd, the smallest disk goes to the target on the first move; if it is even, it goes to the other rod.

Mixed start

In the game's second group the disks do not start as one tower but are spread across the rods in a legal but scattered way: no disk sits on a smaller one. The goal is still to make one tower on the target rod. Think from the largest disk down: if it is on the target, leave it and look at the next one. To move the largest disk that is not on the target, all smaller disks must first be gathered on the third rod. This group has 4 to 8 disks and the fewest moves range from 10 to 169; the game finds the shortest path for each level by searching every possible arrangement.

Four rods

The third group has an extra rod, and the path gets much shorter. With 4 disks, one way is: park the top 2 disks on one of the free rods in 3 moves, move the remaining 2 disks to the target with three rods in 3 moves, then bring the 2 parked disks on top of them in 3 moves. That is 9 moves in total, instead of 15 with three rods. The gap grows with more disks: 8 disks take 33 moves instead of 255. This group has 4 to 8 disks, some levels start scattered, and the fewest moves range from 9 to 33.

Common mistakes

  • Assuming the target is always the rightmost rod: the target is the rod with the gold base and flag; in some levels it is the middle or the left rod.
  • Making the first move at random: in Classic levels, with an odd number of disks the smallest goes to the target first, with an even number it goes to the other rod.
  • Moving the smallest disk twice in a row: in the shortest solution it moves on every other turn; moving it twice wastes a move.
  • Moving the largest disk off the target in a mixed start: it is already in place, and touching it makes the path longer.
  • Ignoring the extra rod in four-rod levels: the three-rod method still works but takes far longer (15 moves instead of 9 with 4 disks).
  • Expecting 3 stars after using a hint: a level where a hint was used gives at most 2 stars, and restarting does not lift that limit.

Frequently asked questions

What is the fewest number of moves in Tower of Hanoi?

With three rods, n disks need 2ⁿ - 1 moves: 3 disks 7, 4 disks 15, 5 disks 31, 8 disks 255.

What are the rules of Tower of Hanoi?

You move one disk at a time, only the top disk can be taken, and a larger disk never goes on a smaller one. The level ends when all the disks are on the target rod.

How do you solve Tower of Hanoi with 3 disks?

If the target is on the right: small right, middle to the middle, small to the middle, large right, small left, middle right, small right. That is 7 moves.

Can a large disk go on an empty rod?

Yes. Any disk can go on an empty rod; the only thing forbidden is putting a larger disk on a smaller one.

How many moves do four rods need?

In our classic four-rod levels, 4 disks take 9 moves, 5 disks 13, 6 disks 17, 7 disks 25 and 8 disks 33.

What is the legend of the 64 disks?

It tells of priests moving 64 golden disks, with the world ending when they finish; the inventor of the puzzle made it up too. 2⁶⁴ - 1 moves at one per second would take about 585 billion years.

What does mixed start mean?

The disks do not start as one tower but spread across different rods in a legal arrangement. You make them one tower on the target; the game works out the shortest path and gives stars against it.

Where can I play Tower of Hanoi?

On CetinsGame, as 24 levels: Classic, Mixed start and Four rods. The site's Mind games collection also has other thinking games such as Chess, Draughts and Mangala.

Play Tower of Hanoi