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 |
OlderNewer