The Tower of Hanoi
The Tower of Hanoi: Solving the Puzzle
The Tower of Hanoi is a classic computer science problem.
The rules are simple: move all the disks on one peg to another peg.
There are only two restrictions:
- You may only move one disk at a time.
- You may not move a larger disk onto a smaller one.
Start the game by choosing a level (those ugly yellow ovals). The minumum number of moves possible to solve the puzzle will appear just beneath the three towers.
Pick up a disk by clicking on (or near) the disk that you want to move. Move it by clicking on any other tower -- remember, the disk you've got has to be smaller than the topmost disk on the tower to which you want to move.
The Tower will change color if you click on it correctly; it will change back to white if you click on it again. Nothing happens if you try to make an illegal move.
Caveats:
- I did this for fun. No, really.
- I'm no Graphics Designer, which explains the homely design. It ain't much, but it's my only child.
- There's a bug on Level 10: the game won't start. That's all right; anyone who's ready to make 1023 moves (and that's the quickest solution!) just to solve this dopy puzzle really has too much time on their hands.
- There's also a graphic bug in there that sometimes makes the left peg look like it has no base.
Here's the source: Tower.java
(Written by Michael Shea.)
Other (Non-professional) Links.
Out to the Front Cover.
E-mail Shea.