Created
October 6, 2014 01:35
-
-
Save toddsundsted/b6ab0bfe693ae13056d6 to your computer and use it in GitHub Desktop.
Haskell H/W: Tower of Hanoi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Peg = String | |
type Move = (Peg, Peg) | |
move :: Integer -> Peg -> Peg -> Peg -> [Move] | |
move 0 _ _ _ = [] | |
move 1 from to _ = [(from,to)] | |
move n from to temp = move (n - 1) from temp to ++ [(from,to)] ++ move (n - 1) temp to from | |
hanoi :: Integer -> Peg -> Peg -> Peg -> [Move] | |
hanoi n a b c = move n a c b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment