From 35f82a2aed37c8daf523ac4c9fbf7112659e8dda Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 1 Dec 2019 09:42:09 +0100 Subject: Start 2019! --- 2019/1.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 2019/1.hs (limited to '2019/1.hs') diff --git a/2019/1.hs b/2019/1.hs new file mode 100644 index 0000000..a3b86f1 --- /dev/null +++ b/2019/1.hs @@ -0,0 +1,13 @@ +module Main where + +import Input + + +main :: IO () +main = do + input <- map read <$> getInput 1 :: IO [Int] + print (sum [n `div` 3 - 2 | n <- input]) + + let compute f = let extra = f `div` 3 - 2 + in if extra <= 0 then 0 else extra + compute extra + print (sum (map compute input)) -- cgit v1.2.3-70-g09d2