blob: 90fe3246a66c92fb6d32399f4b158d1181a32084 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
module Main where
import qualified Data.Array as A
import Numeric.Natural
import Input
import Util
main :: IO ()
main = do
inp <- map read . toList . splitOn (== ',') . head <$> getInput 6
let evolve :: A.Array Int Natural -> A.Array Int Natural
evolve arr = A.accumArray (+) 0 (0, 8) $
[(8, arr A.! 0), (6, arr A.! 0)] ++
[(i, arr A.! (i + 1)) | i <- [0..7]]
initState = A.accumArray (+) 0 (0, 8) [(i, 1) | i <- inp]
after n = sum (A.elems (iterate evolve initState !! n))
print (after 80)
print (after 256)
|