Please don’t rely on this Gitea instance being around forever. If any of your build scripts use my (kageru’s) projects hosted here, check my Github or IEW on Github for encoding projects. If you can’t find what you’re looking for there, tell me to migrate it.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AoC2019/day1.hs

18 lines
417 B

main = do
content <- getContents
putStrLn (show $ foldl getOp 0 (lines content))
getOp :: Int -> String -> Int
getOp acc number = acc + (math (read number)) + getFuel 0 (math(read number))
getFuel :: Int -> Int -> Int
getFuel acc fuel = do
if (math fuel) > 0
then acc + (math fuel) + getFuel acc (math fuel)
else
acc
math :: Int -> Int
math input = ((input `div` 3) - 2)