šŸ—¼

Tower of Hanoi

Move all discs from the left peg to the right peg. You can only place a smaller disc on a larger one.

0
Moves
7
Min Moves
-
Best Moves
Click a peg to select it, then click destination

About Tower of Hanoi

Tower of Hanoi is a classic mathematical puzzle invented in 1883. You have three pegs and a number of discs of different sizes stacked smallest-on-top on the leftmost peg. The goal is to move the entire stack to the rightmost peg in the minimum number of moves.

Controls

  • Click a peg to pick up the top disc from that peg
  • Click another peg to place the held disc there (only valid moves are allowed)
  • Disc count buttons (3–7) - choose how many discs to play with
  • Reset button - restart the puzzle at any time

How to Play

  • Move all discs from the left peg to the right peg.
  • You may only move one disc at a time - always the topmost disc on any peg.
  • A larger disc can never be placed on top of a smaller disc.
  • The minimum number of moves to solve is 2ⁿ āˆ’ 1 (e.g., 7 moves for 3 discs, 31 for 5).
  • Try to solve it in the minimum moves to get a perfect score!

Frequently Asked Questions

The minimum number of moves to solve n discs is 2^n āˆ’ 1. For 3 discs: 7 moves. For 4 discs: 15 moves. For 7 discs: 127 moves. The game tracks your move count.
Yes. The recursive pattern is: move the top nāˆ’1 discs to the auxiliary peg, move the largest disc to the destination, then move the nāˆ’1 discs from auxiliary to destination. Repeat recursively.
No. The only rule is that you cannot place a larger disc on top of a smaller disc. You can place smaller discs on larger ones, or onto empty pegs freely.
You can typically choose from 3 to 7 discs. Start with 3 for a quick puzzle (7 moves), or try 5–7 discs for a more demanding challenge.