Included day 2 puzzle description
[advent-of-code-16.git] / advent02.hs
index 25b78c82c3108f98434a7e34fc36526ce9df91fb..3ea1559d4646e4dc5cb74da01fa2d638d97ad6c2 100644 (file)
@@ -4,11 +4,11 @@ import Data.Array.IArray
 type Position = (Int, Int)
 type Keyboard = Array Position Char
 
-kb1 = [['x', 'x', 'x', 'x', 'x']
-       ['x', '1', '2', '3', 'x']
-       ['x', '4', '5', '6', 'x'],
-       ['x', '7', '8', '9', 'x'],
-       ['x', 'x', 'x', 'x', 'x']]
+kb1 = ["xxxxx"
+       "x123x"
+       "x456x",
+       "x789x",
+       "xxxxx"]
 
 kb2 = ["xxxxxxx",
        "xxx1xxx",
@@ -21,7 +21,7 @@ kb2 = ["xxxxxxx",
 enumerate = zip [0..]
 
 mkKeyboard :: [String] -> Keyboard
-mkKeyboard kb = array ((0, 0), (length kb - 1, length kb - 1))
+mkKeyboard kb = array ((0, 0), (length kb - 1, length (kb!!0) - 1))
     [((i, j), c) | (i, r) <- enumerate kb, (j, c) <- enumerate r]
 
 keyboard1 = mkKeyboard kb1