summaryrefslogtreecommitdiff
path: root/2017/2.hs
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-12-02 10:00:47 +0100
committertomsmeding <tom.smeding@gmail.com>2017-12-02 10:00:47 +0100
commit56c25dfeafde1aeed8ddad43b6041b065a82bdda (patch)
treeab96749ed73987ee0930de9a9a9a92097bb069c1 /2017/2.hs
parent2c1dccf57d7ad5e25e79063dea41fd7bfa9d9ac6 (diff)
Start 2017!
Diffstat (limited to '2017/2.hs')
-rw-r--r--2017/2.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/2017/2.hs b/2017/2.hs
new file mode 100644
index 0000000..47ff161
--- /dev/null
+++ b/2017/2.hs
@@ -0,0 +1,13 @@
+import Control.Monad
+
+main :: IO ()
+main = do
+ input <- liftM (map (map read . words) . lines) (readFile "2.in") :: IO [[Int]]
+
+ print $ sum [maximum l - minimum l | l <- input]
+
+ let f = fst . head .
+ filter ((/=1) . fst) . filter ((==0) . snd) .
+ concat . concatMap (\(a,b) -> [map (a `divMod`) b, map (`divMod` a) b]) .
+ (\l -> zip l (repeat l))
+ print $ sum $ map f input