The Towers of Hanoi is a mathematical puzzle consisting of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.

The objective of the puzzle is to move the entire stack to another rod, obeying the following rules:

  • Only one disk may be moved at a time.
  • Each move consists of taking the upper disk from one of the rods and sliding it onto another rod, on top of the other disks that may already be present on that rod.
  • No disk may be placed on top of a smaller disk.

It turns out that if there are n number of disks, it will take a minimum of 2^n-1 number of moves to solve the puzzle. I won’t explain where the 2^n-1 comes from, that’s the whole point of solving the puzzle and for you to figure out!

What I like most about this puzzle is its origin. The puzzle was invented by the French mathematician Édouard Lucas in 1883. There is a legend about a temple in Hanoi, Vietnam which contains a large room with three time-worn posts in it surrounded by 64 golden disks. The monks at the temple acting out the command of an ancient prophecy, have been moving these disks, in accordance with the rules of the puzzle, since that time. According to the legend, when the last move of the puzzle is completed, the world will end. It is not clear whether Lucas invented this legend or was inspired by it.

If the legend were true, and if the monks were able to move the disks at a rate of one per second, using the smallest number of moves, it would take them 2^{64}-1 seconds or roughly 585 billion years; it would take 18,446,744,073,709,551,615 turns to finish.

I shared this story with my precalc students yesterday when I introduced exponential functions. I like how it demonstrates how fast exponential functions grow.

Advertisements