home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-19 | 1.6 KB | 61 lines | [TEXT/CWIE] |
- (*
- Problem 02 - Hower of Tanoi
-
- This problem is to solve a variant of the Tower of Hanoi puzzle. You remember
- the Tower of Hanoi, a board with three pegs, one of which has N disks of size
- 1, 2, 3, ... N, with the smallest disk at the top. In the standard puzzle, the
- goal is to move all of the disks from one peg to another peg, by repeatedly
- moving a disk from the top of one peg to another peg without ever placing a
- larger disk on top of a smaller disk.
-
- In our Hower of Tanoi problem, the objective and the constraints are the same,
- except that the disks on the first peg are initially in random order. You can
- still only move a smaller disk onto a larger disk.
-
- Your objective is output the moves required to place all the disks on peg 3 in
- order with the smallest disk at the top.
-
- Input specification
-
- The first line of the input file contains an integer M, M<1000, the number of
- disks in the problem. The next M lines contain the numbers 1 .. M, one number
- per line, randomly ordered, where the first number is the size of the top disk
- on peg 1, the second number is the size of the 2nd disk from the top, etc.
-
- Output specification
-
- The output is a sequence of lines, each representing a single move, consisting
- of the source peg number followed by a comma (',') followed by the destination
- peg number, followed by a return character.
-
- Sample input
-
- 2
- 2
- 1
-
- Sample output
-
- 1,3
- 1,3
- *)
-
- unit Solution;
-
- interface
-
- // Do not modify the interface
-
- uses
- Types, Files;
-
- function HowerOfTanoi( const infile, outfile: FSSpec ): OSErr;
-
- implementation
-
- // Fill in your solution and then submit this folder
-
- // Team Name: FILL IN YOUR TEAM NAME!
-
- end.
-