Tower of Hanoi online
In the Tower of Hanoi you move every disc from one peg to the target peg, one disc per move and never a larger disc onto a smaller one. Choose 3 to 10 discs; with n discs you need at least 2ⁿ − 1 moves. The hint shows the next move of a shortest solution. No sign-up, works on phones.
Source: Wikipedia: Tower of Hanoi (Regeln, 2ⁿ − 1 Züge, Lösungsalgorithmus). Updated: .
How it is calculated
In short: The Tower of Hanoi is a puzzle with three pegs and a stack of discs of different sizes. You move the whole stack to another peg without ever placing a larger disc on a smaller one. With n discs the fastest solution takes 2ⁿ − 1 moves.
The rules
- Move exactly one disc per turn, and only the top disc of a peg.
- Place it on an empty peg or on a larger disc.
- At the end all discs sit in their original order on the target peg (peg 3, marked with a star).
How many moves are needed at least?
| Discs | Minimum moves |
|---|---|
| 3 | 7 |
| 4 | 15 |
| 5 | 31 |
| 6 | 63 |
| 7 | 127 |
| 10 | 1,023 |
Every extra disc doubles the moves and adds one: 2ⁿ − 1. The formula comes from the method: first move the upper n − 1 discs to the spare peg, then the largest disc to the target, then the n − 1 discs back on top of it.
Step-by-step strategy
The smallest disc moves on every second turn. With an even number of discs move it 1 → 2 → 3 → 1, with an odd number 1 → 3 → 2 → 1. On the turns in between there is exactly one legal move that does not involve the smallest disc – make it. The “Hint” button shows the next move of a shortest solution, “Play best move” plays it for you.
Puzzle series
“Next puzzle” walks you through a series: no. 1 to 7 are standard towers with 3 to 9 discs; from no. 8 on every puzzle starts from a different legal position with a changing target peg. Your progress stays on your device only.
Frequently asked questions
How many moves does the Tower of Hanoi need?
With n discs at least 2ⁿ − 1 moves: 7 for 3 discs, 15 for 4, 31 for 5, 1,023 for 10. It is proven that fewer is impossible.
How do I get started?
Move the smallest disc on every second turn: with an even number of discs first to peg 2, with an odd number first to peg 3. In between, make the only other legal move.
What if I made a wrong move?
The hint works out the next move of a shortest path to the goal from any position. “Undo” takes back your last move.
Where does the puzzle come from?
The French mathematician Édouard Lucas invented it in 1883. The legend of the monks with 64 golden discs was part of the original box.
Is my progress saved?
Only which puzzle numbers you solved, and only in your browser (localStorage). Nothing is sent anywhere.
Sources and legal basis
As of: · Editorial policy
Related tools
- Sliding puzzle with your own photoFree sliding puzzle: the classic 15 puzzle in 3×3, 4×4 or 5×5 – with numbers or your own photo. Solvable shuffles only; your photo stays in your browser.
- Play sudoku online – daily puzzle and solverPlay sudoku online free: a new daily sudoku every day plus 4 levels, notes, mistake check and hints. The solver explains every step. Printable grid.
- Mastermind game onlinePlay the Mastermind game online for free: crack the colour code in 10 tries, three levels with a hint button and a challenge link. No sign-up, works on phones.
- Play Binairo onlinePlay Binairo online for free: a puzzle of 0s and 1s in three sizes and levels, always uniquely solvable, with hints that explain the reason. No sign-up needed.
- Play nonograms onlineFree nonogram puzzles in your browser: 5×5, 10×10 and 15×15, numbered levels and random puzzles – each with exactly one solution. With hints and error check.
- Play Solitaire OnlineFree Klondike solitaire in your browser: draw 1 or 3, unlimited undo, hints and a winnable daily deal. Share your time – the link deals the same cards.
- Spelling bee words: random word generatorSpelling bee words at random: spin for a word from six lists, from grade 1 to hard words for adults. No repeats, add your own list, for class or home practice.
- Badminton scoreboard onlineBadminton scoreboard online and free: tap to add a point, games end automatically at 21 (or 15), with service court, interval and change of ends. No app.
- This or that questions generatorThis or that questions at random: spin for one of 108 questions – for kids, food, funny, work, teens and couples. Add your own and play in class or at parties.