AoC/2021/day06/day06.hs
2021-12-14 01:29:53 +01:00

15 lines
418 B
Haskell

import Data.List.Split
main :: IO ()
main = do
input <- map read <$> splitOn "," <$> readFile "day06/input"
print $ day06 input 80
print $ day06 input 256
day06 :: [Int] -> Int -> Int
day06 input days = sum $ map (\x->last $ take x fibFish) i
where i = map ((+3) . (+ days) . abs . subtract 6) input
fibFish :: [Int]
fibFish = zipWith (+) ((take 7 $ repeat 1) ++ fibFish) ((take 9 $ repeat 0) ++ fibFish)