Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  tower hanoi problem (Roelof Wobben)
   2. Re:  tower hanoi problem
      (Sumit Sahrawat, Maths & Computing, IIT (BHU))
   3. Re:  tower hanoi problem (Roelof Wobben)
   4. Re:  tower hanoi problem (Dudley Brooks)


----------------------------------------------------------------------

Message: 1
Date: Tue, 17 Feb 2015 18:09:38 +0100
From: Roelof Wobben <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] tower hanoi problem
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150217/7ad7eb1a/attachment-0001.html>

------------------------------

Message: 2
Date: Tue, 17 Feb 2015 23:37:50 +0530
From: "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
        <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] tower hanoi problem
Message-ID:
        <CAJbEW8M6u=UEcWNvazwY_vNLh06hF2Nxp6qDg-gY_faCeW=v...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

hanoi 1 p1   _ p3 = move 1 disc from p1 to p3
hanoi n p1 p2 p3 = move n discs from p1 to p3 using p2 in between

The definition of the first equation is easy. To complete the second
equation, you need to use hanoi again recursively.
I detailed a way to complete the second equation in my previous mail (which
hopefully didn't spoil it).

Hope this helps.

On 17 February 2015 at 22:39, Roelof Wobben <[email protected]> wrote:

>  Stupid error
>
> Then it must be like this :
>
> hanoi n 1 2 3
>     | n = 1 -> moves the last disk to the goal peg
>     | n > 1 -> moves all the other disk to the spare peg or to the  moves
> n -1 to the goal peg
>
>
> Roelof
>
>
> Mike Meyer schreef op 17-2-2015 om 17:57:
>
>  On Feb 17, 2015 10:50 AM, "Roelof Wobben" <[email protected]> wrote:
> >
> > N reprent the number of disk
>
> So how does moving 0 disks happen? That is what your first case deals with.
>
> > Roelof
> >
> >
> > Mike Meyer schreef op 17-2-2015 om 17:47:
> >>
> >>
> >> On Feb 17, 2015 10:18 AM, "Roelof Wobben" <[email protected]> wrote:
> >> >
> >> > This part I understand well.
> >> >
> >> > So you could do something like this:
> >> >
> >> > hanoi n 1 2 3
> >> >    | n = 0 -> moves the last disk to the goal peg
> >> >    | n != 0 -> moves all the other disk to the spare peg or to the
> moves n -1 to the goal peg
> >>
> >> What does n represent here?
> >>
> >>
> >>
> >> _______________________________________________
> >> Beginners mailing list
> >> [email protected]
> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
> >
> >
> >
> > _______________________________________________
> > Beginners mailing list
> > [email protected]
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
> >
>
>
> _______________________________________________
> Beginners mailing 
> [email protected]http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>


-- 
Regards

Sumit Sahrawat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150217/acc26ced/attachment-0001.html>

------------------------------

Message: 3
Date: Tue, 17 Feb 2015 19:43:47 +0100
From: Roelof Wobben <[email protected]>
To: [email protected],  The Haskell-Beginners Mailing
        List - Discussion of primarily beginner-level topics related to
        Haskell <[email protected]>
Subject: Re: [Haskell-beginners] tower hanoi problem
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150217/54a4767d/attachment-0001.html>

------------------------------

Message: 4
Date: Tue, 17 Feb 2015 11:42:59 -0800
From: Dudley Brooks <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] tower hanoi problem
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"; Format="flowed"

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 <[email protected] 
> <mailto:[email protected]>> 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
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150217/73199e8f/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 80, Issue 38
*****************************************

Reply via email to