On Thu, Feb 19, 2015 at 1:11 AM, Roelof Wobben <r.wobben@home.nl> wrote:
I think I found the answer by some trail and error,

hanoi 1 start _ end = [ (start, end)]
hanoi n start temp end = hanoi (n-1) start end temp ++ [(start, end)] ++ hanoi (n-1) temp start end

main = print $ hanoi 3 'a' 'b' 'c'

I mentioned earlier that using "hanoi 1 start temp end" instead of "[(start, end)]" made things read a bit better to me. I figured out why. It isolates the final representation of a "move" to the base case only. So if you make that change, you could then write your base case as:

hanoi 1 start _ end = "move 1 disk from " ++ start ++ " to " ++ end ++ ".\n"  

and the other case still works correctly if you used the "hanoi 1" version. You'll want to change "print" to "putStr" in main, but it will now print the list of moves in English instead of Haskell.