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
2016-03-27 14:11:47 +02:00

14 lines
204 B
Haskell

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 ]