This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
CIS194/Homework 1/hanoi.hs

14 lines
204 B
Haskell
Raw Normal View History

2016-03-27 12:11:47 +00:00
type Peg = String
type Move = (Peg, Peg)
hanoi :: Integer -> Peg -> Peg -> Peg -> [Move]
hanoi 1 a b c = [(a, c)]
hanoi n a b c = concat [
hanoi (n-1) a c b,
hanoi 1 a b c,
hanoi (n-1) b a c ]