[Haskell-beginners] Difficulty understanding the Towers of Hanoi exercise from CIS194

John Del Rosario john2x at gmail.com
Sun Aug 30 06:27:49 UTC 2015


I've just completed the first exercise (Credit Card Number Validation)
and was quite happy with myself.

But moving on to the next exercise I found myself having trouble trying
to understand some parts of the question.

I've solved Towers of Hanoi before with an imperative language,
but I'm having trouble visualising the steps described in this paragraph:

To move n discs (stacked in increasing size) from peg a to peg b using peg c
as temporary storage,
1. move n-1 discs from a to c using b as temporary storage
2. move the top disc from a to b
3. move n-1 discs from c to b using a as temporary storage.

I've never seen the solution described this way before.
So if I start with 5 discs, then for the first step I'll be moving 4 (n-1) discs? But
can't I only move 1 disc at a time?

And step 2 says to move the top disc from a to b. Which disc is the top disc at this point?

I'm still in a very imperative mindset (and having no formal training doesn't help),
but I'm hoping that will improve as I go through this course!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150830/0b8a8c09/attachment.html>


More information about the Beginners mailing list