Tower of Hanoi Unblocked
Three pegs, a pile of rings and one rule: wide never goes on narrow.
What is Tower of Hanoi?
Tower of Hanoi is a single-player puzzle with three pegs and a pile of rings sorted by size. Rings travel one per move, and a wider ring may never cover a narrower one. You win by rebuilding the full pile on the far right peg, ideally using the minimum number of moves.
- Category
- Puzzle Games
- Players
- 1 player
- Plays on
- Phone, tablet & desktop
- Input
- Keyboard, Mouse, Touch
- Made by
- Douile
- Checked
The Tower of Hanoi puzzle is the famous ring-and-peg challenge that maths teachers love, because its solution hides a beautiful pattern. A pile of colored rings starts on the left peg, widest at the base, and has to end up rebuilt on the right. Only a single ring travels per move, and a wide ring may never sit on top of a narrower one. This version by Douile runs unblocked on a plain black canvas, shows your moves next to the perfect total, lets you add more rings, and can even solve itself while you watch.
Rules and the Move Counter
Lift whichever ring is on top of a peg, carry it across and let go. Bare pegs and wider rings are fine landing spots; narrower rings are not. While you hold a ring, it hovers above the selected peg, so you can see where it is about to go.
The opening setup has three rings and a seven-move best. Plus adds a ring and minus takes one away, but never below three. Any change resets the board.
Up in the corner, the tally reads something like 11/7: moves you have made, then the minimum possible. Land the final ring on the right peg and the view zooms in briefly to celebrate. A perfect score means your number matches the target.
| Rings | Minimum moves |
|---|---|
| 3 | 7 |
| 4 | 15 |
| 5 | 31 |
| 6 | 63 |
Tower of Hanoi controls
| To do this | Keyboard | Mouse | Touch |
|---|---|---|---|
| Lift or set down a ring | Space, Enter, Up/Down arrows or W/S | Click a peg | Tap a peg |
| Move between pegs | Left/Right arrows or A/D | — | — |
| Start the puzzle again | R | Click the circular arrows icon | Tap the circular arrows icon |
| Change the ring count | — | Click the plus or minus icon | Tap the plus or minus icon |
| Let the game solve it | — | Click the play icon, click again to stop | Tap the play icon, tap again to stop |
The Pattern Behind a Perfect Solve
You don’t have to memorise anything. Two simple ideas get you there every time.
Idea one: the smallest ring leads
In a flawless run, the tiniest ring moves on every second turn and keeps rotating around the three pegs one consistent way. If the ring count is odd, it opens by hopping to the right. If the count is even, it opens by hopping to the middle.
Idea two: the in-between move is forced
On the turns when the tiny ring rests, there is only ever one legal move among the other two pegs. Make it, then move the small ring again.
Thinking recursively
Another way to see it: to move a tower of five, first move the top four to the middle peg, then shift the biggest ring across, then move the four back on top of it. Each smaller tower is solved the same way. This is why the puzzle shows up in computer science lessons on recursion.
Good For Learners and Perfectionists
Tower of Hanoi is great for students meeting recursion, for kids learning to plan, and for anyone who likes chasing a flawless move count. Watching the solver handle a four- or five-ring stack makes the rhythm easy to spot, and then the fun is matching it yourself with seven or eight rings.
If you like classic solo puzzles, try Peg Solitaire next. For sliding-tile ordering, Fifteen Slide is another old favourite.
Tower of Hanoi: questions players ask
What is the minimum number of moves for Tower of Hanoi?
It is two to the power of the number of rings, minus one. Three rings need 7 moves, four need 15, five need 31 and six need 63. The game shows this target after the slash in the move counter.
Does putting a ring back on the same peg count?
Yes. Every drop adds one to the counter, even if the ring returns to where it started. Decide where a ring is going before you pick it up.
How do you solve Tower of Hanoi with 4 rings?
Move the top three rings to the middle peg, which takes seven moves. Move the biggest ring to the right peg. Then move the three rings from the middle onto it in another seven, for 15 total.
Can I stop the auto-solver and take over?
You can stop it by pressing play again, but starting it once more begins from the beginning rather than resuming. It works best as a demonstration you watch, then reset and copy.
Credits and license
Tower of Hanoi was created by Douile and released as open source. FreezeNova hosts a lightly adapted copy on its own server, together with the original license file.
- Source code: github.com/Douile (original project)
- Code license: MIT
- Art & audio: MIT (rings and pegs drawn in code; Feather icons, MIT)
- Our changes: We added click and tap controls, an on-screen restart button and a canvas that fits our frame, and took out an outbound GitHub link. The rules and the solver are the same as the original.