[Haskell-beginners] tower of hanoi problem

Roelof Wobben r.wobben at home.nl
Sat Feb 14 12:43:18 UTC 2015


Hello,

I try to answer your questions. Maybe then it is clear where My thinking 
gets the wrong turn.
>
> · Divide your input into two cases: the terminal one that ends the 
> recursion and the one you recurse on.

I think the terminal one is when there is no moves anymore so when a and 
b are empty and c holds all the disk.


> · Decide how to handle the terminal case. In this case, you'll return 
> a list consisting of one move.

There is a problem. I thought I must return all the moves then.

> · 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.

two subproblems ?  I can only think about one and that is looking what 
the next move can be.


> · Write the code that makes the non-terminal calls and combines their 
> values to create your return value.

Oke, when I have the right answers to the former questions, I can think 
about how to solve this one.
>
> In cases where your function returns a list, the combination is almost 
> always appending one case to the other.

I also think so , so it will be old case ++ new case because otherwise 
it will display in the wrong order.



Roelof




More information about the Beginners mailing list