next next up down toc toc mail

6.2.  Tower of Hanoi

The Tower of Hanoi puzzle is as follows: There are three vertical pegs, usually attached to a board. On the middle peg are stacked several disks of decreasing radius (of course each disk has a hole in its center for the peg)

The object is simple: Move the tower of disks to another peg, given two restrictions:

a)
You may only move one disk at a time, i.e. only one disk may be un-pegged at any time.
b)
You may never put a larger disk atop a smaller one.

The algorithm as a Nassi Shneidermann diagram:

Procedure move(int n_rings, peg from, peg to, peg over):

[picture]


back next up down toc toc mail


Created by unroff & hp-tools. © by Hans-Peter Bischof. All Rights Reserved (1998).

Last modified: 27/July/98 (12:14)