IQ-25
Logic puzzles

Tower of Hanoi: rules, recursive solution and minimum moves

Learn the recursive Tower of Hanoi solution and why three disks require seven moves.

Tower rules

Disks occupy three pegs, initially stacked on the left. Move only a top disk each turn. A larger disk cannot rest on a smaller one. The goal is to transfer the stack to the right peg in size order.

Break the problem into three steps

To move n disks from A to C, move n−1 disks from A to B using C. Move the largest disk from A to C. Then move n−1 disks from B to C using A. A single disk requires just one move. This is the recursive structure of the puzzle.

Minimum moves

Before moving the largest disk, all smaller disks must be on the spare peg. Afterward they must be moved onto the largest disk. Thus T(n)=2T(n−1)+1, with T(1)=1, giving T(n)=2ⁿ−1. Three disks require 7 moves and four require 15. Additional moves are possible but not needed for an optimal solution.

Practice

Solve three disks first, stating the goal of each subproblem. Then try four, treating the top three as a separate tower. Compare your move count with the theoretical minimum, not just speed. If confused, identify the largest disk that is not yet on the target peg.

Common questions

How many moves for four disks?

At least 15, from 2⁴−1.

Practical example

How do you move two disks from A to C?

Show explanation

Small A→B, large A→C, small B→C. Three moves.

Put it into practice

Move the disks to the right peg

Tower of Hanoi

Useful reading

All articles