1
0
Fork 0
advent-of-code/2020/11/Part1.hs
Sloane Perrault 9ed563e239 wip: day 11
2022-09-21 09:19:53 -04:00

16 lines
449 B
Haskell
Executable file

#!/usr/bin/env runghc
module Day11.Part1 where
import Day11
import Data.List (find)
import Data.Array (elems)
main = interact (show . solve . parse)
-- unlines $ map (render . snd) $ takeWhile (not . isUnchanged) ticks
solve start = length $ filter (== Occupied) $ elems stasis
where
simulation = iterate tick start
ticks = zip simulation (tail simulation)
isUnchanged = uncurry (==)
(Just (stasis, _)) = find isUnchanged ticks