Clever Games Tower of Hanoi is a free online logic puzzle that asks you to move a stack of disks from the left peg to the right peg, one disk at a time, never placing a larger disk on a smaller one. Play Tower of Hanoi with 3 to 10 disks, see the minimum number of moves, and watch the animated solution from any position, with no sign-up.
How to play Tower of Hanoi?
Move the whole tower from the left peg to the right peg, which is marked Goal. You move one top disk per turn, and a larger disk may never sit on a smaller one. The board opens with the tower ready, so you can start at once.
- Pick a tower size. Choose 3 to 10 disks in the Disks menu beside the board. A new player starts with 3 disks in the first-move tutorial, and the board opens with 4 disks by default after that.
- Pick up a disk. Tap or click the peg that holds the disk you want, or drag its top disk. The disk lifts above the peg to show it is selected.
- Put it down. Tap the peg where it should go. It lands softly if the move is legal. If a larger disk would land on a smaller one, the move is refused, that peg shakes and a line beside the board explains why.
- Keep the spare peg busy. The middle peg is a place to park disks while you free a larger one underneath.
- Finish on the Goal peg. When the whole tower stands on the right peg, the result panel shows your moves and your time, and the counter beside the board still shows the minimum. Press Play again to try the same tower for fewer moves.
Keyboard: press 1, 2 or 3 to choose the source peg, then 1, 2 or 3 again for the destination. Pressing the same key a second time, or Esc, cancels the selection. Ctrl+Z undoes a move and Ctrl+Y redoes it.
The dashed outline shows where the largest disk must end up. Every other disk has to leave the way first, which is the whole idea of the puzzle.
What are the rules of Tower of Hanoi?
The rules of Tower of Hanoi are short: move one disk at a time, take only the top disk of a stack, and never place a larger disk on a smaller one. The tower starts on the left peg and must end on the right peg.
An empty peg accepts any disk. A peg that holds disks accepts only a disk smaller than its current top disk. You cannot lift a disk from the middle of a stack or slide one out from underneath another.
There is no losing here. A wrong move never ends the round and nothing counts mistakes, so you can try a route and take it back with Undo. Redo replays a move you undid. Restart sets the tower back to its starting position.
For a tower of n disks, the shortest possible solution takes 2ⁿ−1 moves. The counter beside the board shows your moves and that minimum, and the timer next to the Disks menu shows the elapsed time. You can finish in more moves than the minimum, and the round still counts as solved.
Why 2ⁿ−1? To move the largest disk, all smaller disks must first sit on the spare peg. That is one smaller tower move, then one move of the large disk, then the same smaller tower move again. So the count for n disks is twice the count for n−1 disks plus one, and that pattern gives 2ⁿ−1.
How many disks can you use, and which modes does the Tower of Hanoi have?
You choose a tower of 3 to 10 disks, with 4 as the default, and the page has two tabs: Play and Learn. Each tower size has one fixed starting position, so a 6-disk tower always begins the same way.
| Disks | Minimum moves | A good fit for |
|---|---|---|
| 3 | 7 | First round, the tutorial size |
| 4 | 15 | Default size, a quick round |
| 5 | 31 | Practicing the repeating pattern |
| 6 | 63 | Planning several moves ahead |
| 7 | 127 | A longer, steady round |
| 8 | 255 | Players who like long sequences |
| 9 | 511 | A real endurance challenge |
| 10 | 1023 | The largest tower on the page |
The Play tab is the board you control. The Learn tab shows a plain-words explanation of recursion and pseudocode you can copy, and Auto-solve plays the recursive solution as an animation on the same board while the line being carried out is highlighted. The playback speed is under Options. Learn works on a copy of your board and pauses your timer, so switch to it when you want to see the pattern, then return to Play and try it yourself.
Each size keeps its own record under Stats: rounds played, rounds solved and best time. If you leave a round unfinished, it is saved on this device and opens where you stopped when you come back. Press Restart if you would rather begin that tower again.
At the end of a round you get a rating based on moves only, never on time. Exactly the minimum is “Expert pace”. Up to one and a half times the minimum is “Steady pace”. Anything above that is “Keep practicing”. After a result, More disks adds a bigger tower to your next round.
What tips help you solve the Tower of Hanoi?
The best tip for Tower of Hanoi is to ask where the largest unplaced disk must go, then clear the way for it. Plan for that disk first, and the smaller moves fall into place.
Start with 3 disks and say each goal out loud: move the top two disks to the middle peg, move the big disk to the Goal peg, then move the two disks on top of it. Every bigger tower repeats this same three-part plan.
The smallest disk moves every other turn in an optimal solution. If you are unsure what to do next, move the smallest disk, then make the only other legal move that does not undo your last one. With an odd number of disks the smallest disk steps toward the Goal peg each time. With an even number it steps toward the middle peg first.
Count your moves against the minimum as you go. If the counter runs ahead of your plan, you have probably undone your own work. Undo a few moves and look for the point where a larger disk was moved too early.
When you are stuck, press Hint. It highlights the next move of a shortest route from the current position, and there is no limit on hints.
How does Auto-solve from here work in the Tower of Hanoi?
Auto-solve from here is the page’s main feature. It takes the tower exactly as it stands, even after a detour, and animates the shortest way to finish, not only from the start.
Press Auto-solve and the disks move on their own. The Speed choice under Options sets the pace, from 0.5× to 16×, and Stop hands control back to you. Touching a peg or pressing Undo also stops it.
A round finished this way is marked “Solved by auto-solve. Try it yourself?” and offers Play again to start the same tower over. It gets no rating, it does not count as a player-solved round in your records, and it does not extend your streak. That keeps your own results honest.
Why can the solver start anywhere? Because the recursive idea works from any legal position. Find the largest disk that is not yet where it belongs. Gather all smaller disks on the spare peg, move that disk to its target peg, then bring the smaller disks onto it. Each of those steps repeats the same idea on a smaller tower.
The Learn tab shows the version from the starting position as pseudocode:
transfer(n, from, target, spare):
if n == 0: return
transfer(n-1, from, spare, target)
move top disk from from to target
transfer(n-1, spare, target, from)
Read it as “move the n−1 smaller disks out of the way, move the big disk, then move the smaller disks back on top.” The function calls itself with a smaller tower each time, which is what recursion means.
Who is Tower of Hanoi especially useful for?
Tower of Hanoi suits anyone who wants a short, clear logic puzzle, and it is especially useful for students, teachers, seniors, families and commuters.
- Students meet recursion with a board they can touch. Learn highlights each line of the pattern as it plays, and the minimum-moves counter backs up the 2ⁿ−1 formula from class.
- Teachers can project the Learn tab, set a slow speed and ask the class to predict the next move before it plays. Auto-solve from a student’s own position makes a good discussion starter.
- Seniors get a calm puzzle with no time limit, big touch targets, and an undo that never runs out.
- Families can take turns on one device. Start with 3 disks for beginners and add disks as everyone gets comfortable.
- Commuters can finish a 3- or 4-disk round in about two minutes, and an unfinished round waits on the device until the next ride.
What are the benefits of playing Tower of Hanoi?
Playing Tower of Hanoi gives you practice in planning ahead, in breaking a big task into smaller ones and in keeping a goal in mind while you work on something else. These are skills the puzzle exercises. It makes no medical or health promises.
- Logic: every legal move follows from a short rule, so you learn to test an idea against the rule before you act.
- Memory: a 6-disk or larger tower asks you to hold the current subgoal in mind while you carry out the moves.
- Focus: one wrong lift can cost many moves, so the puzzle rewards steady attention.
- Problem solving: the same trick works at every size, so one insight helps on every tower.
- Patience: the minimum counter lets you compare routes without any penalty for experimenting.
What is the history of the Tower of Hanoi?
The Tower of Hanoi is a mathematical puzzle first published by the French mathematician Édouard Lucas in 1883. It was sold as a toy with a box of eight disks and three pegs.
Lucas told a story to go with it. In a temple, priests were said to move a tower of 64 golden disks between three posts, one disk at a time. When the last move was finished, the legend said, the world would end. The story is an invention that helps people remember the puzzle.
The legend carries a real mathematical point. A tower of 64 disks needs 2⁶⁴−1 moves, a number larger than 18 quintillion. Even at one move per second, that is far longer than anyone could play, which shows how fast a doubling pattern grows.
Since then the puzzle has become a standard example in teaching recursion and in introductory computer science, because its shortest solution follows directly from a repeating pattern. The Learn tab on this page is built on that same pattern.
What are the most frequently asked questions about Tower of Hanoi?
How do you play Tower of Hanoi?
Move the whole stack of disks from the left peg to the right peg, one disk at a time. Take only the top disk of a peg, and never put a larger disk on a smaller one. Tap or drag, or use the keys 1, 2 and 3.
How do you work out the minimum number of moves?
For n disks the minimum is 2ⁿ−1. That is 7 moves for 3 disks, 15 for 4, and 1023 for 10. The counter bar shows this minimum for the tower you chose.
Can the puzzle get stuck after a wrong move?
No. Every legal move can be undone, and the solver can finish from any legal position. A poor move only makes your route longer.
What does Auto-solve from here do?
It animates the shortest finish from your current position, with a speed choice under Options and a Stop button. A round finished this way is not counted as solved by you and does not extend your streak.
What is the Learn tab?
Learn explains recursion in plain words and shows pseudocode you can copy. Press Auto-solve there to watch the recursive solution on the same board, with the current line highlighted. Your own round waits unchanged until you return to Play.
Is there a limit on hints or time?
No. Hint shows the next best move as often as you like, and nothing ends the round when time passes. The timer only records how long you took.
How many disks are there?
You can play 3 to 10 disks. A first visit begins with a short tutorial on 3 disks, and after that the board opens with 4 disks.
Can I play without a mouse?
Yes. Press 1, 2 or 3 to pick the source peg and again for the destination. Esc cancels a selection, and Ctrl+Z and Ctrl+Y undo and redo.