From 4127c9dad6b58e2b108414ca5bb407eb5d941903 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 27 Mar 2016 14:11:47 +0200 Subject: [PATCH] 3 peg hanoi solver --- Homework 1/hanoi.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Homework 1/hanoi.hs diff --git a/Homework 1/hanoi.hs b/Homework 1/hanoi.hs new file mode 100644 index 0000000..17906dc --- /dev/null +++ b/Homework 1/hanoi.hs @@ -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 ] + + +