Algorithms

Tower of Hanoi

A puzzle with 3 pegs and n disks of different sizes: they all must move from one peg to another, 1 at a time and never placing a big one on a small one.

Example

With 3 disks it takes 7 moves; with 10, 1,023. It is always 2ⁿ − 1.

Test yourself: Tower of Hanoi

Tower of Hanoi

Which of these moves is forbidden?

Lessons that use it

More algorithms terms

All terms →

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.