[Haskell-beginners] tower hanoi problem

Doug McIlroy doug at cs.dartmouth.edu
Fri Feb 20 02:27:10 UTC 2015


On 2/19/15 4:47 AM, Joel Neely wrote:

> Incidentally, I also find it interesting to see the subtle effects
> that our terminology has on the  way we approach problems. Thinking of
> a list as "it may be empty or not" takes my thoughts in a different
> direction than if I think "it may have a head or not".

A telling aphorism. It will stick with me for a long time.

Regarding the problem that sparked this discussion, Hanoi: if you 
think first about the base case, it's likely to be this: to transfer
a oone-disc pile from A to B using C as an intermediate, move A to B.
If you think first about the recursive step, you'll likely come
up with a different base case: to transfer zero discs, do nothing. 
With this insight, you've generalized your original understanding 
of the problem.

Doug


More information about the Beginners mailing list