Skip to content

Instantly share code, notes, and snippets.

View toddsundsted's full-sized avatar

Todd Sundsted toddsundsted

View GitHub Profile
@toddsundsted
toddsundsted / gist:b6ab0bfe693ae13056d6
Created October 6, 2014 01:35
Haskell H/W: Tower of Hanoi
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