Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/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.  tower of hanoi problem (Roelof Wobben)
   2.  tower hanoi problem (Roelof Wobben)
   3. Re:  tower hanoi problem (Steven Williams)
   4. Re:  tower hanoi problem (Roelof Wobben)
   5. Re:  tower of hanoi problem (Mike Meyer)


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

Message: 1
Date: Fri, 13 Feb 2015 20:39:29 +0100
From: Roelof Wobben <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] tower of hanoi problem
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20150213/953b5cd2/attachment-0001.html>

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

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

An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20150213/04478799/attachment-0001.html>

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

Message: 3
Date: Fri, 13 Feb 2015 15:16:24 -0600
From: Steven Williams <[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=windows-1252

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I am really horrible at helping people which is why I delayed replying
to this. Your email got through to the list twice, you don't need to
send it again.

The steps you need to take are in the homework assignment. The items
1-3 are literally the algorithm you need to use. Something to keep in
mind is that the pegs can change per function call. For example
initially you call it with "hanoi 2 a b c", then hanoi calls itself
again with "hanoi 1 a c b" to achieve one of the steps that you need
to take.

Steven Williams
My PGP Key: http://pgp.mit.edu/pks/lookup?op=get&search=0xCACA6C74669A54FA

On 02/13/2015 03:09 PM, Roelof Wobben wrote:
> Hello,
> 
> After a short break I try to make the next assignment of the CIS
> 194 course. I do self-study.
> 
> Lets say we have 1 disk with 2 pegs then we have this :
> 
> 
> type Peg = String. type Move = (Peg, Peg) Hanoi :: Integer -> Peg
> -> Peg -> [Move]
> 
> So I can do this Hanoi 2 a b
> 
> How can I proceed further.
> 
> I do not see how I can tell that the disk can move from a to b And
> I do not see what the base case will be . I think when a is empty 
> and b has a value.
> 
> Can anyone shine a light on this matter without telling me the
> answer ?
> 
> Roelof
> 
> typ
> 
> 
> 
> _______________________________________________ Beginners mailing
> list [email protected] 
> http://www.haskell.org/mailman/listinfo/beginners
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJU3mmnAAoJEMrKbHRmmlT6zHMP/iOKoYXJejbt7CbEGsVhCvEl
HXm1qPDNY+1wRAVVVmyCPSY3xXieE8Q+yPagfS4DhzUhsJjCnXZ1ZUBvm+Bx0tww
427ofFTuMYlrQ2gFlT2feHTm2l3NfSeeOQ8KiWS1XT6/UxQddarF8GIyO2tp29b8
51NxiOLJJpfGmGK0u2i0moDqMavHLeKWERToUrfkhTHcSVzyC7Aw4zAiG2ScaRzD
CrYjIRq8SLB38svs8X31jx4vGVsVvwvCnoxReNjCNfYULgOHjfXE4kRz+pb0fScc
A46uIkNxZ34sQdIWbuGbVe4sGDQl+BUh0HzdRDtviMbj38attE8WAjd8r+3SRpr9
ZgFoXGbj1Z0l9Pm82auvrKRX5aP2OmVAkCCyQW/PrsqRq8Ezz+t1bC0jNlYQbQc+
tgWUoQFeejJgxvmFqp693wpFe9gkbZ7pTjKYXFtv22IHsb7vlW9+Hhe7qxsLRPF9
QuSh1mkBElnK604b79HV8HtPmRezuQtFlKgmnkoT/fcu2KaAvReIdnGkTgjbs1qW
JTvTCnxI9wHGUPpBLh8F5bx79UH/rKh43rz5IQZIA/fqwS+25OkFpAbm7UhB6pOh
vknsLjaH4yzTqMJT15IWF/RMXITgMengmon2hzjzySqxEeK84rO8kIrOzYMqK3dr
Z6ZSaA1o8Ba00Iz6EMpS
=7773
-----END PGP SIGNATURE-----


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

Message: 4
Date: Fri, 13 Feb 2015 22:25:55 +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=windows-1252; format=flowed

Thanks,

Is it the second time a c b because the next step will be a disk from 
the a to the c disk ?

Roelof



Steven Williams schreef op 13-2-2015 om 22:16:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I am really horrible at helping people which is why I delayed replying
> to this. Your email got through to the list twice, you don't need to
> send it again.
>
> The steps you need to take are in the homework assignment. The items
> 1-3 are literally the algorithm you need to use. Something to keep in
> mind is that the pegs can change per function call. For example
> initially you call it with "hanoi 2 a b c", then hanoi calls itself
> again with "hanoi 1 a c b" to achieve one of the steps that you need
> to take.
>
> Steven Williams
> My PGP Key: http://pgp.mit.edu/pks/lookup?op=get&search=0xCACA6C74669A54FA
>
> On 02/13/2015 03:09 PM, Roelof Wobben wrote:
>> Hello,
>>
>> After a short break I try to make the next assignment of the CIS
>> 194 course. I do self-study.
>>
>> Lets say we have 1 disk with 2 pegs then we have this :
>>
>>
>> type Peg = String. type Move = (Peg, Peg) Hanoi :: Integer -> Peg
>> -> Peg -> [Move]
>>
>> So I can do this Hanoi 2 a b
>>
>> How can I proceed further.
>>
>> I do not see how I can tell that the disk can move from a to b And
>> I do not see what the base case will be . I think when a is empty
>> and b has a value.
>>
>> Can anyone shine a light on this matter without telling me the
>> answer ?
>>
>> Roelof
>>
>> typ
>>
>>
>>
>> _______________________________________________ Beginners mailing
>> list [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
>
> iQIcBAEBAgAGBQJU3mmnAAoJEMrKbHRmmlT6zHMP/iOKoYXJejbt7CbEGsVhCvEl
> HXm1qPDNY+1wRAVVVmyCPSY3xXieE8Q+yPagfS4DhzUhsJjCnXZ1ZUBvm+Bx0tww
> 427ofFTuMYlrQ2gFlT2feHTm2l3NfSeeOQ8KiWS1XT6/UxQddarF8GIyO2tp29b8
> 51NxiOLJJpfGmGK0u2i0moDqMavHLeKWERToUrfkhTHcSVzyC7Aw4zAiG2ScaRzD
> CrYjIRq8SLB38svs8X31jx4vGVsVvwvCnoxReNjCNfYULgOHjfXE4kRz+pb0fScc
> A46uIkNxZ34sQdIWbuGbVe4sGDQl+BUh0HzdRDtviMbj38attE8WAjd8r+3SRpr9
> ZgFoXGbj1Z0l9Pm82auvrKRX5aP2OmVAkCCyQW/PrsqRq8Ezz+t1bC0jNlYQbQc+
> tgWUoQFeejJgxvmFqp693wpFe9gkbZ7pTjKYXFtv22IHsb7vlW9+Hhe7qxsLRPF9
> QuSh1mkBElnK604b79HV8HtPmRezuQtFlKgmnkoT/fcu2KaAvReIdnGkTgjbs1qW
> JTvTCnxI9wHGUPpBLh8F5bx79UH/rKh43rz5IQZIA/fqwS+25OkFpAbm7UhB6pOh
> vknsLjaH4yzTqMJT15IWF/RMXITgMengmon2hzjzySqxEeK84rO8kIrOzYMqK3dr
> Z6ZSaA1o8Ba00Iz6EMpS
> =7773
> -----END PGP SIGNATURE-----
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>



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

Message: 5
Date: Fri, 13 Feb 2015 15:54:07 -0600
From: Mike Meyer <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] tower of hanoi problem
Message-ID:
        <CAD=7u2ddtsh5_yovjpyyyfyzwdnyfrc_kjawh5_gyr0kmdo...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Fri, Feb 13, 2015 at 1:39 PM, Roelof Wobben <[email protected]> wrote:

>  Hello,
>
> After a short break I try to make the next assignment of the CIS 194
> course.
> I do self-study.
>
> Lets say we have 1 disk with 2 pegs then we have this :
>
>
> type Peg = String.
> type Move = (Peg, Peg)
> Hanoi :: Integer -> Peg -> Peg -> [Move]
>
> So I can do this Hanoi 2 a b
>
> How can I proceed further.
>
> I do not see how I can tell that the disk can move from a to b
> And I do not see what the base case will be . I think when a is empty and
> b has a value.
>

It's a recursion problem. So you tackle it like any other recursion problem:
? Divide your input into two cases: the terminal one that ends the
recursion and the one you recurse on.
? Decide how to handle the terminal case. In this case, you'll return a
list consisting of one move.
? Decide how to divide the non-terminal case into at least two sub-problems
that are all closer to the terminal case by some measurement.
? Write the code that makes the non-terminal calls and combines their
values to create your return value.

In cases where your function returns a list, the combination is almost
always appending one case to the other.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20150213/0ca30abb/attachment-0001.html>

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

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


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

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

Reply via email to