
Um ... To the other people giving hints: Don't forget that in the sequence *of lines in the program* you have to state the base case(s) *first*, certainly in Haskell, which goes through the lines in order, until it finds a match. That's what I meant when I said "first do the base case(s), then the rest": first *in the program order*, if not necessarily in the conceptual structure. So for the depth-first binary tree which Joel Neely pointed out, *first* you must deal with the base case that the node being looked at is actually a leaf; *only then* can you deal with the fact that in general the algorithm has the structure <process left descendants><process this node><process right descendants>. So if you try <move stack off of bottom><move bottom><place stack on bottom>, the first part will either enter an endless loop or will generate an error, because it doesn't have a base case. (No pun on "base" intended.) On 2/17/15 4:05 AM, Joel Neely wrote:
Let's tweak your answers just a bit, calling the three pegs the "source", "goal", and "spare" pegs:
On Tue, Feb 17, 2015 at 5:23 AM, Roelof Wobben
mailto:r.wobben@home.nl> wrote: - Where do I move the bottom (largest disk) ?
To the last peg, which do not contain any disk then .
From the source peg to the goal peg, which will /must not contain any disks.
- What must happen before I can move the bottom disk ?
I have to move the disk which above that disk.
Move everything else from ____ to ____.
- What must happen after I move the bottom disk ?
All the other disk must be placed above that disk.
Move everything else from ____ to ____.
So more questions/hints:
1. How do you fill in the blanks? 2. How do you put the three statements in order? 3. How many disks does each statement talk about?
-jn-
-- Beauty of style and harmony and grace and good rhythm depend on simplicity. - Plato
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners