Skip to content

How to play the Tower of Hanoi

The Tower of Hanoi has three pegs and a stack of discs of different sizes, largest at the bottom. Move the whole stack to another peg. You may move only one disc at a time, always the top disc of a peg, and you may never place a disc on top of a smaller one. With n discs the fewest moves needed is 2ⁿ − 1.

How to play Tower of Hanoi

  1. Move one disc at a time, taking it from the top of a peg.
  2. Place it on an empty peg or on a larger disc, never on a smaller one.
  3. Move the smallest disc every other turn, always in the same circular direction.
  4. On the turns in between, make the only legal move that does not use the smallest disc.
  5. Finish when the whole tower stands on the target peg.

Tower of Hanoi rules

Setup

  1. Three pegs. All the discs start on one peg, in order of size with the largest at the bottom.

Moving

  1. Only one disc moves at a time.
  2. Only the top disc of a peg can be moved.
  3. A disc may go onto an empty peg or onto a larger disc. It may never sit on a smaller disc.

Winning

  1. The puzzle is solved when the whole tower, in the same order, is on another peg.

Tower of Hanoi tips

  • Know the minimum

    3 discs take at least 7 moves, 4 take 15, 5 take 31 and 6 take 63. Each extra disc doubles the work and adds one: 2ⁿ − 1.

  • Pick the smallest disc's direction

    With an even number of discs, the smallest disc moves start → spare → target → start, round and round. With an odd number, it goes start → target → spare → start. Choosing right ensures the tower ends on the target peg.

  • Alternate moves

    Every second move is the smallest disc's. On the other moves exactly one legal move exists that does not touch the smallest disc. Following these two rules solves any tower in the minimum number of moves.

  • Think in smaller towers

    To move a tower of 4, first move the top 3 to the spare peg, then move the big disc to the target, then move the 3 on top of it. Each smaller tower is solved the same way. This is why the puzzle is the classic example of recursion.

Where to play Tower of Hanoi

  • Gridwise

    Logic puzzles in one calm app

    • Gridwise's line for it is 'Move the tower across'; Disc tower and Move the discs are its other names.
    • Levels are quick, at about 2 minutes.
    • There are 300 levels along its path.
    • Pip can point out the next legal move.

Questions about Tower of Hanoi

  • What is the minimum number of moves for the Tower of Hanoi?

    2ⁿ − 1 for n discs: 7 for 3 discs, 15 for 4, 31 for 5 and 63 for 6.

  • What is the trick to solving the Tower of Hanoi?

    Move the smallest disc every other turn, always cycling in the same direction, and in between make the one legal move that does not involve it.

  • Can you put a bigger disc on a smaller one?

    No. A disc can only go onto an empty peg or onto a larger disc.

  • Why is the Tower of Hanoi used to teach recursion?

    Moving n discs means moving n − 1 discs out of the way, moving the largest, and moving n − 1 discs back on top. The same steps repeat for each smaller tower.

Facts checked against the game's own design documents on .

More games like Tower of Hanoi

  • Water Sort: rules

    Also called Color sort

    Pour the top run onto the same colour or an empty bottle until each one holds one colour.

    • Color Sort
    • Gridwise

    2 min a round

  • Pipe Puzzle: rules

    Also called Connect the pipes

    Turn pipes to connect

    • Gridwise

    1 min a round

  • Unblock Car: rules

    Also called Traffic jam

    Slide cars out of the way

    • Gridwise

    2 min a round

  • Sokoban: rules

    Also called Box pusher

    Push crates onto targets

    • Gridwise

    4 min a round