Re-add first solution from temporary aoc repo

This commit is contained in:
Joscha 2019-12-05 08:54:33 +00:00
parent acf0e97b86
commit c0c9e1c623
4 changed files with 44 additions and 8 deletions

19
hs/src/Aoc/Y2019/A01.hs Normal file
View file

@ -0,0 +1,19 @@
module Aoc.Y2019.A01
( solve201901
) where
fuel :: Integer -> Integer
fuel n = (n `div` 3) - 2
iteratedFuel :: Integer -> Integer
iteratedFuel = sum . takeWhile (> 0) . tail . iterate fuel
solve201901 :: FilePath -> IO ()
solve201901 f = do
values <- (map read . lines) <$> readFile f
putStr "Total fuel: "
print $ sum $ map fuel values
putStr "Total fuel (iterated): "
print $ sum $ map iteratedFuel values