Skip to content

Instantly share code, notes, and snippets.

@lykkin
Created February 24, 2015 21:01
Show Gist options
  • Save lykkin/a9a05c30bdb8c9d7b608 to your computer and use it in GitHub Desktop.
Save lykkin/a9a05c30bdb8c9d7b608 to your computer and use it in GitHub Desktop.
type Peg = String
type Move = (Peg, Peg)
hanoi :: Integer -> Peg -> Peg -> Peg -> [Move]
hanoi disks from to storage | disks > 1 = (hanoi (disks - 1) from storage to) ++ [(from, to)] ++ (hanoi (disks - 1) storage to from)
| otherwise = [(from, to)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment