Introduction to Computer Science II

Assignment for 2007-Sep-07


The Towers of Hanoi is a fun little puzzle. There are a set of rings, each of different sizes, and three posts. At the start of the game, all of the rings must be stacked on the first post, from largest (on the bottom) to smallest (on the top). Your objective is to move the stack of rings from the first post onto one the third post, keeping the stack in the same order (largest to smallest, bottom to top).

The trick is that there are strict rules about moving the rings:

  1. Only one ring may be moved at a time.

  2. To begin a move, only a ring at the top of its stack (that is, on a post) may be chosen.

  3. To end a move, the ring must be place at the top of one of the three stacks.

  4. A larger ring may not be placed on top of a smaller ring.

Your assignment: Figure out how to solve this puzzle! Know how to successfully move the stack of rings, under the given rules, from one post to another.


This assignment is due on Friday, 2007-Sep-07, at 1:00 pm

Scott F. H. Kaplan
Last modified: Fri Sep 14 15:23:12 EDT 2007