Tower of Hanoi

Hanoi.zip

The Tower of Hanoi puzzle was invented by the French mathematician Edouard Lucas in 1883. We are given a tower of ten disks (initially three in the flash movie above), initially stacked in increasing size on one of three pegs. The objective is to transfer the entire tower to one of the other pegs (the rightmost one in the flash movie above), moving only one disk at a time and never a larger one onto a smaller.

The puzzle is well known to students of Computer Science since it appears in virtually any introductory text on data structures or algorithms. Its solution touches on two important topics: For more information see [A. Bogomolny, Tower of Hanoi from Interactive Mathematics Miscellany and Puzzles. http://www.cut-the-knot.org/recurrence/hanoi.shtml]

The flash movie is created, by me, using Actionscript 2.0 in Flash 8. The algoritm, to solve the puzzle, runs and each move is saved in an array. Each move in the array is then animated sequentially. This requires some synchronization using the setInterval function.