Towers of Hanoi

There are three pegs p1, p2 and p3. k disks of different sizes are all placed on peg p1 according to decreasing diameter (the largest one is at the bottom, the smallest one is at the top). Disks can be moved from one peg to another, one disk at a time, subject to the following constraints:

  1. disk cannot be moved unless it is the top disk on its peg
  2. disk cannot be placed on a disk of smaller size.
INPUT: A set of ground atoms "block(i)", i=1,2,...,k, where k is the number of blocks. The ground atom "block(i)" expresses the fact that i is a block.

OUTPUT: a sequence of moves accomplishing the task.

DATA SETS:  no data sets are needed

NOTES:

  1. Suggested values for k: 4, 5, 6, possibly 7