The Tower of Hanoi is a classic puzzle where n discs move between three pegs. The Tower of Hanoi calculator gives the minimum number of moves 2ⁿ − 1, the time to solve it, the moves of the smallest disc, the moves of any disc and the largest puzzle that can be solved in a lifetime.
How the calculation works
- Enter the number of discs on the first peg. The classic puzzle with 3 pegs is solved by moving one disc at a time, never putting a larger disc on a smaller one.
- Enter the time for one move in seconds, to get the total time to solve the puzzle.
- Enter the number of a disc to follow, with 1 for the smallest. The smallest disc moves every other move, and the largest moves only once.
- The calculator gives the minimum number of moves 2ⁿ − 1, the time, the number of moves of the smallest disc 2ⁿ⁻¹, the moves of the disc you follow 2ⁿ⁻ᵏ and the largest puzzle you could solve in 80 years.
Example
With 12 discs, the minimum number of moves is 2¹² − 1 = 4,095. At one move per second, the puzzle takes 1 hour 8 minutes 15 seconds. The smallest disc moves 2¹¹ = 2,048 times. The fifth disc moves 2⁷ = 128 times. With non-stop play for 80 years at one move per second, you could solve a puzzle of up to 31 discs, which needs 2,147,483,647 moves.
Why it matters
The calculator helps students, teachers and puzzle fans to see how fast an exponential grows, to plan a classroom demonstration with a number of discs that can be solved in time, and to illustrate recursion in computer science. It shows why each disc added doubles the work.
Good to know
The formula gives the minimum number of moves for the three-peg puzzle with the standard rules. With four or more pegs, the minimum number of moves is much smaller and is given by the Frame-Stewart conjecture. For a demonstration, plan the time for mistakes, since the real time is longer than the minimum. The number of discs is limited to 50.
Related tools
The logarithm calculator reverses a power of two, the exponential growth calculator models repeated doubling, the arithmetic-geometric series calculator sums related sequences, and the Fibonacci calculator explores another famous recurrence.