About Tower of Hanoi
Tower of Hanoi is the classic peg-and-ring puzzle, built by Douile. Three pegs stand side by side, and a stack of rings sits on the first one, largest at the bottom. Your goal is to move the whole stack to the peg on the right. You can lift only the top ring of a peg, and a ring can never go on top of a smaller one.
A counter in the corner shows your moves next to the fewest moves possible. With three rings, the best solution takes 7 moves, and every extra ring roughly doubles that. Add rings with the plus button for a harder puzzle, remove them down to three, or restart at any time. Stuck? The play button makes the puzzle solve itself so you can watch the pattern unfold. It suits anyone who likes calm brain teasers, and it is a neat way to see recursion in action.
How to play Tower of Hanoi
- Click or tap a peg - pick up its top ring, or drop the ring you are holding
- Left/Right arrows or A/D - move the selection between pegs
- Space, Enter, Up/Down arrows or W/S - pick up or drop a ring
- R or the circular arrows icon - restart the puzzle
- Plus or minus icon - add or remove a ring
- Play icon - watch the puzzle solve itself (press again to stop)
Playing Tower of Hanoi on a computer
Click a peg to pick up its top ring, then click another peg to drop it there. Keyboard players can move between pegs with the left and right arrows or A and D, and press Space or Enter to lift or drop. R restarts the puzzle. Tip: the counter shows your moves next to the minimum, so try to match it.
Playing Tower of Hanoi on a phone or tablet
Tower of Hanoi works well with touch. Tap a peg to lift its top ring and tap the peg where it should go. The icons let you restart, change the number of rings or watch the puzzle solve itself. The board fits a phone either way, though turning it sideways gives the pegs more room.
Tips and tricks
- With an odd number of rings, move the smallest ring to the target peg first; with an even number, move it to the middle peg first.
- The smallest ring moves on every other turn, always cycling around the pegs in the same direction.
- Use the move counter to check yourself: matching the minimum means you found the perfect solution.
- Watch the auto-solve once, then try to repeat the pattern on your own with one more ring.
Game details
| Developer | Douile |
|---|---|
| Category | Puzzle |
| Platform | Desktop and mobile |
| Technology | HTML5 (open source) |
| Price | Free |
| Original game | Douile/tower-of-hanoi by Douile |
| Code license | MIT |
| Art and sound | MIT (rings and pegs drawn in code; Feather icons, MIT) |
| Hosted copy | Adapted to run on GN Math - see the changes |
Tower of Hanoi FAQ
What is the fewest number of moves?
For n rings, it is 2 to the power of n, minus 1. That is 7 moves for three rings, 15 for four and 31 for five.
Can I make Tower of Hanoi harder?
Yes. Press the plus icon to add rings; the minus icon removes them, down to a minimum of three.
Does Tower of Hanoi work on phones and Chromebooks?
Yes. Tap a peg to pick up its top ring and tap another peg to drop it. On a Chromebook you can click or use the keyboard.





























