🗼 Tower of Hanoi

Move all discs from the left column to the right column! Only small discs can be placed on top of large discs. Aim for completion in the fewest number of moves.

Discs:
number of moves (in go, shogi, etc.)
0
Minimum
7
Progress
0%
Velocity
A
B
C

CLEARED! Congratulations!

way of playing (a game)

  • Move all disks in pillar A (left) to pillar C (right)
  • Click on the column you want to move to select it (highlighted in orange)
  • Then click on the column to be moved to confirm the move.
  • Only a small disc can be placed on top of a large disc.
  • The "Auto Solve" button animates the best solution.

What is Tower of Hanoi?

Tower of Hanoi is a timeless puzzle game where players move a stack of disks from one peg to another while obeying a single rule: never place a larger disk on a smaller one. This seemingly simple constraint creates an engaging logic puzzle that teaches recursive thinking and strategic planning. Perfect for both casual gaming and understanding fundamental algorithms in computer science.

How to Use

The game presents three vertical pegs with disks stacked on the left peg in descending size order. Click any disk to select it, then click the destination peg to move it. The game prevents invalid moves—you cannot place a larger disk over a smaller one. Your goal is to reconstruct the entire stack on the right peg. The puzzle displays move count to encourage optimization. Easier puzzles start with 3-4 disks; challenge yourself by increasing disk count to 7 or 8 for significantly greater complexity.

Use Cases

Logic Training: Daily puzzle solvers use Hanoi to sharpen problem-solving and patience, similar to crosswords or Sudoku
Algorithm Education: Computer science students visualize recursive algorithms by solving progressively larger puzzles
Cognitive Development: Teachers use Hanoi for children's math and logic classes to develop spatial reasoning
Strategy Gaming: Casual gamers enjoy the meditative challenge of finding the minimum move solution (2^n - 1 moves)
Interview Preparation: Tech candidates study Hanoi algorithm explanations for recursion interview questions

Tips & Insights

The minimum solution follows a mathematical formula: for n disks, you need exactly 2^n - 1 moves. With 3 disks, that's 7 moves; 4 disks requires 15 moves; 7 disks demands 127 moves. The recursive pattern: solve tower of (n-1) disks on auxiliary peg, move largest disk to destination, then solve tower of (n-1) disks on destination. Recognizing this pattern transforms random trial-and-error into systematic, elegant solutions. Moving the smallest disk in odd positions follows a specific direction—grasping this rhythm accelerates solving.

Frequently Asked Questions

What are the rules?

Move all discs from the left column (A) to the right column (C). Only smaller discs can be placed on top of larger discs.

What is the minimum number of moves?

If there are n discs, the minimum number of moves is 2ⁿ-1; if there are 3 discs, the minimum is 7 moves; if there are 8 discs, the minimum is 255 moves.

What is an automatic solution?

Pressing the "Auto Solve" button animates the best solution.

How to operate?

Click on the source column to select it, then click on the destination column to move it.

Why is the minimum number of moves 2^n - 1, and does that matter for gameplay?

The minimum represents the mathematically optimal solution; understanding it helps you recognize when you're making unnecessary moves. For 10 disks it's 1,023 moves—realizing this helps develop strategic thinking and patience.

What strategies help solve Tower of Hanoi faster without using the automatic solution?

Focus on the largest disks first and move them in a fixed pattern. For odd-numbered disk puzzles, always move in one direction; for even-numbered ones, move in the opposite direction. This systematic approach beats random attempts.

Does difficulty increase significantly between 5 disks and 10 disks?

Exponentially—5 disks requires 31 moves while 10 disks requires 1,023 moves. Most people find 7-8 disks mentally engaging but solvable; 10+ requires true patience or systematic algorithmic thinking.

What cognitive benefits does solving Tower of Hanoi provide?

It strengthens problem-solving, planning, and working memory. Researchers use it to test cognitive function, and regular practice improves your ability to think several steps ahead and break complex problems into manageable sub-problems.

Can I compete with others or try speedrunning Tower of Hanoi?

Yes, speedrunning is a legitimate challenge where top players solve 8-10 disks incredibly fast with practiced movements. You can manually time yourself or set personal improvement goals rather than competing for world records.

Is Tower of Hanoi just a game, or does it have real-world applications?

It's used in cognitive research, computer science education to teach recursion, and neuroscience to study decision-making. Understanding the algorithm teaches principles applicable to programming, logistics, and complex task planning.