[Haskell-beginners] tower hanoi problem

Mike Meyer mwm at mired.org
Sat Feb 14 21:51:17 UTC 2015


Do you want to see the list for those two cases? Because in either the
recursive or iterative solution, there's only two cases.

The 2-disk moves are: [(a, c), (a, b), (c, b)]
The 3-disk moves are: [(a, b), (a, c), (b, c), (a, b), (c, a), (c, b), (a,
b)]


On Sat, Feb 14, 2015 at 3:40 PM, YCH <dontdieych at gmail.com> wrote:

> Would you mind show code for only two cases? Just think about two cases.
>
> hanoi 2 a b c
> hanoi 3 a b c
> 2015. 2. 15. 오전 6:35에 "Roelof Wobben" <r.wobben at home.nl>님이 작성:
>
>>  I know.
>>
>> Eveyone says there is a pattern but I do not see it at the moment.
>>
>> Maybe I do the wrong first move with more then 2 disk.
>>
>> You can put the first disk on the second or the thirth peg.
>>
>> Roelof
>>
>>
>> Mike Meyer schreef op 14-2-2015 om 22:30:
>>
>>
>>
>> On Sat, Feb 14, 2015 at 3:27 PM, Roelof Wobben <r.wobben at home.nl> wrote:
>>
>>> KC schreef op 14-2-2015 om 22:23:
>>>
>>>>
>>>> Hint:
>>>>
>>>> - think about what you need to do in each recursive step and in the
>>>> base case
>>>>
>>>> - there is also an interesting way of viewing the problem
>>>>
>>>>
>>>>
>>> Check if I can do another step or check if the end case all disk are on
>>> the last peg.
>>>
>>> Im very curious what the interesting way is
>>>
>>
>>  I suspect it's the iterative version that was already mentioned here.
>> You were close to discovering it when worked through the problem on paper.
>>
>>
>> _______________________________________________
>> Beginners mailing listBeginners at haskell.orghttp://www.haskell.org/mailman/listinfo/beginners
>>
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20150214/13330d93/attachment.html>


More information about the Beginners mailing list