Created
June 4, 2014 05:32
-
-
Save GrooveStomp/a02cabe16a1746741b32 to your computer and use it in GitHub Desktop.
Towers of Hanoi (3 Pegs)
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
| type Peg = String | |
| type Move = (Peg, Peg) | |
| hanoi :: Integer -> Peg -> Peg -> Peg -> [Move] | |
| hanoi 1 p1 p2 _ = [(p1, p2)] | |
| hanoi n p1 p2 p3 = hanoi (n - 1) p1 p3 p2 ++ [(p1, p2)] ++ hanoi (n - 1) p3 p2 p1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment