From 56c25dfeafde1aeed8ddad43b6041b065a82bdda Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 2 Dec 2017 10:00:47 +0100 Subject: Start 2017! --- 2017/1.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 2017/1.hs (limited to '2017/1.hs') diff --git a/2017/1.hs b/2017/1.hs new file mode 100644 index 0000000..884e00e --- /dev/null +++ b/2017/1.hs @@ -0,0 +1,12 @@ +import Control.Monad +import Data.Char + +main :: IO () +main = do + input <- liftM (filter isDigit) $ readFile "1.in" + + print $ sum $ map (\(a,b) -> read [a] * fromEnum (a == b)) $ + zip input (tail (cycle input)) + + print $ sum $ map (\(a,b) -> read [a] * fromEnum (a == b)) $ + zip input (drop (length input `div` 2) (cycle input)) -- cgit v1.2.3-70-g09d2