Towers of Annoyed [From the Archives]

My “Day I Left Pennsylvania” led me to some archived website posts (before blogs were invented) I had written many years ago. I’m re-posting them now. Bear in mind that most of the content in this series is over 5 years old. I have left the content more or less intact. I have removed some links and added some others — but that’s it. Enjoy!


(Just kidding, it’s “Towers of Hanoi” :) )

hanoiAny first or second-year computer programmers have likely run into this problem, most likely when they first get introduced to recursion.

Legend has it that in a temple in the Far East, priests are attempting to move a stack of disks from one peg to another. The initial stack had 64 disks threaded onto one of three pegs and arranged from bottom to top by decreasing size. The priests are attempting to move the stack from that peg to a second peg. The only constraints are that disks must be moved one at a time, and at no time may a larger disk be placed above a smaller disk. A third peg is available for temporarily holding disks.(Supposedly the world will end when the priests finish, so you would kind of wonder why we would want to help them, eh? ;^)

Ok, that’s a mouthful! Let’s start by breaking this down into some simpler rules: Continue reading