3 peg hanoi solver
This commit is contained in:
parent
c698ebb625
commit
4127c9dad6
13
Homework 1/hanoi.hs
Normal file
13
Homework 1/hanoi.hs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
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 ]
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user