The Tower of Hanoi Problem

The Legend. In an ancient city in India, so the legend goes, monks in a temple have to move a pile of 64 sacred disks from one location to another. The disks are fragile; only one can be carried at a time. A disk may not be placed on top of a smaller, less valuable disk. And, there is only one other location in the temple (besides the original and destination locations) sacred enough that a pile of disks can be placed there.

So, the monks start moving disks back and forth, between the original pile, the pile at the new location, and the intermediate location, always keeping the piles in order (largest on the bottom, smallest on the top). The legend is that, before the monks make the final move to complete the new pile in the new location, the temple will turn to dust and the world will end. Is there any truth to this legend?

The Problem (based on this legend). You have a small collection of disks (with holes in the center) and three pegs onto which you can put them. The disks all start on the leftmost peg, and you want to move them to the rightmost peg, never putting a disk on top of a smaller one.

Try to solve this problem yourself.

In the SIPE-2 plan drawing, there is only one action:

MOVEDISC Moves the named disk from its current peg to the given peg

If the arguments are printed, the first argument in the disk (DA is the smallest, DB the next smallest, etc.), and the second argument is the peg to which it should move (A, B, or C). The pegs start on peg A and must move to peg C.

Click here to see the SIPE-2 input file for Tower of Hanoi.

Back to Wilkins Home Page Back to SIPE-2 Home Page

David E. Wilkins
Last modified: Tue May 4 18:46:15 1999