This commit is contained in:
Gattix 2021-12-14 01:29:53 +01:00
parent 8a8721bb26
commit f1b6c5d311
3 changed files with 16 additions and 0 deletions

14
2021/day06/day06.hs Normal file

@ -0,0 +1,14 @@
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)

1
2021/day06/input Normal file

@ -0,0 +1 @@
1,3,4,1,5,2,1,1,1,1,5,1,5,1,1,1,1,3,1,1,1,1,1,1,1,2,1,5,1,1,1,1,1,4,4,1,1,4,1,1,2,3,1,5,1,4,1,2,4,1,1,1,1,1,1,1,1,2,5,3,3,5,1,1,1,1,4,1,1,3,1,1,1,2,3,4,1,1,5,1,1,1,1,1,2,1,3,1,3,1,2,5,1,1,1,1,5,1,5,5,1,1,1,1,3,4,4,4,1,5,1,1,4,4,1,1,1,1,3,1,1,1,1,1,1,3,2,1,4,1,1,4,1,5,5,1,2,2,1,5,4,2,1,1,5,1,5,1,3,1,1,1,1,1,4,1,2,1,1,5,1,1,4,1,4,5,3,5,5,1,2,1,1,1,1,1,3,5,1,2,1,2,1,3,1,1,1,1,1,4,5,4,1,3,3,1,1,1,1,1,1,1,1,1,5,1,1,1,5,1,1,4,1,5,2,4,1,1,1,2,1,1,4,4,1,2,1,1,1,1,5,3,1,1,1,1,4,1,4,1,1,1,1,1,1,3,1,1,2,1,1,1,1,1,2,1,1,1,1,1,1,1,2,1,1,1,1,1,1,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,2,5,1,2,1,1,1,1,1,1,1,1,1

1
2021/day06/testinput Normal file

@ -0,0 +1 @@
3,4,3,1,2