Created
May 24, 2015 16:49
-
-
Save ignacy/f99bcdad951e8c252b94 to your computer and use it in GitHub Desktop.
Towers of Hanoi in haskell
This file contains hidden or 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
| module TowersOfHanoi where | |
| type Peg = String | |
| type Move = (Peg, Peg) | |
| hanoi :: Integer -> Peg -> Peg -> Peg -> [Move] | |
| hanoi 0 _ _ _ = [] | |
| hanoi n a b c = (hanoi (n - 1) a c b) ++ [(a, b)] ++ (hanoi (n - 1) c b a) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hanoi 2 "a" "b" "c" == [("a","c"), ("a","b"), ("c","b")]