🗼 How to solve the Tower of Hanoi (method and trick)
By Miguel Arechaga
The Tower of Hanoi is a mathematical puzzle with more than a century of history and a place of honor in computer science, because it perfectly illustrates the idea of "solving a problem by breaking it into smaller ones." Here's the method to solve it every time.
What is the Tower of Hanoi?
There are three towers and a stack of disks of different sizes, stacked from largest (bottom) to smallest (top) on the first tower. The goal is to move the whole stack to the last tower, following two rules: only one disk moves at a time, and a larger disk can never end up on top of a smaller one.
How to play
- Tap the source tower to pick up the top disk, then tap the destination tower.
- You can never place a larger disk on top of a smaller one.
- You win when you've moved the entire stack to the tower on the right.
- Try to do it in the minimum number of moves. You can choose from 3 to 6 disks.
The recursive method (that never fails)
The secret is thinking "top-down." To move a stack of N disks from tower A to tower C using B as support, always do the same thing:
- Move the top N−1 disks from A to B (the auxiliary tower).
- Move the largest disk from A to C.
- Move the N−1 disks from B to C, on top of the large one.
Each of those "move N−1 disks" steps is solved by repeating the same idea with a smaller stack. It's a pattern that repeats inward until it reaches a single disk, which just moves directly.
The minimum-moves trick
The minimum number of moves for N disks is exactly 2^N − 1: 7 for 3 disks, 15 for 4, 31 for 5, and 63 for 6. There's even a practical trick: if you always move the smallest disk in the same circular direction and, on the in-between turns, make the only other legal move available, you'll solve the puzzle in the minimum without even thinking about it.
The Tower of Hanoi is a beautiful exercise in logic and planning. Once you understand the recursive pattern, solving it for any number of disks is just a matter of repeating the recipe.
🏆 Best-games ranking
The Tower of Hanoi has its own global ranking: it saves your solve with the fewest moves. Go to Ranking, the 🕹️ 1 Player tab, choose "Tower of Hanoi" from the dropdown, and compare your score with other players, synced to your account. For your result to count you need a free account on MundoSudoku (just a username and password, no email required): you can play without one, but without signing in your score isn't saved to the ranking.
Put what you've learned into practice.
🎮 Play Tower of Hanoi for free 🕹️ See all games