Tower of Hanoi Example Runs
Three-disk Full Solution
$ python3 tower.py A: 3 2 1 B: C: Move disk from tower? A Move disk to tower? C A: 3 2 B: C: 1 Move disk from tower? A Move disk to tower? B A: 3 B: 2 C: 1 Move disk from tower? C Move disk to tower? B A: 3 B: 2 1 C: Move disk from tower? A Move disk to tower? C A: B: 2 1 C: 3 Move disk from tower? B Move disk to tower? A A: 1 B: 2 C: 3 Move disk from tower? B Move disk to tower? C A: 1 B: C: 3 2 Move disk from tower? A Move disk to tower? C A: B: C: 3 2 1 *** Victory! ***
Invalid Moves & QUIT
$ python3 tower.py A: 3 2 1 B: C: Move disk from tower? B Move disk to tower? C Invalid move! A: 3 2 1 B: C: Move disk from tower? A Move disk to tower? B A: 3 2 B: 1 C: Move disk from tower? A Move disk to tower? B Invalid move! A: 3 2 B: 1 C: Move disk from tower? QUIT
Bad Inputs
$ python3 tower.py A: 3 2 1 B: C: Move disk from tower? nowhere Invalid tower! Move disk from tower? A Move disk to tower? over there Invalid tower! Move disk to tower? QUIT