15 lines
392 B
Haskell
15 lines
392 B
Haskell
|
main = do
|
||
|
content <- readFile "input"
|
||
|
let input = lines content
|
||
|
print (day11 input)
|
||
|
print (day12 input)
|
||
|
|
||
|
|
||
|
day11 :: [String] -> Int
|
||
|
day11 xs = sum $ map ((subtract 2) . floor . (/ 3) . read) xs
|
||
|
|
||
|
day12 :: [String] -> Int
|
||
|
day12 xs = (sum $ map (f . read) xs) - (sum $ map read xs) where
|
||
|
f x | x>0=x+f (((subtract 2) . floor . (/ 3) . fromIntegral) x)
|
||
|
| otherwise = 0
|