15 lines
418 B
Haskell
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)
|