The Tower of Hanoi is a stack-moving puzzle game that features three poles on which you can stack various-sized disks. The object of the game is to move one tower of disks to another pole. However, only one disk can be moved at a time, and larger disks cannot be placed on top of smaller ones. Figuring out a certain pattern will help you solve this puzzle. Can you discover it? (Hint: Try setting the
TOTAL_DISKS variable to
4 to solve an easier version first.)
The Program in Action
When you run towerofhanoi.py, the output will look like this:
The Tower of Hanoi, by Al Sweigart firstname.lastname@example.org Move the tower ...