← All posts

Interactive: Tower of Hanoi

Tower of Hanoi

The Tower of Hanoi is a classic puzzle. You have three pegs and a stack of discs — each disc is smaller than the one below it. The goal is simple: move the entire stack to the right peg.

The rules:

  • Move only one disc at a time.
  • A larger disc can never sit on top of a smaller one.

With n discs, the minimum number of moves is 2ⁿ − 1. It grows fast. Five discs need 31 moves. Ten need 1,023. The algorithm behind it is pure recursion.