diff --git a/2021/day20.hs b/2021/day20.hs index ccf8cf7..ce849dd 100644 --- a/2021/day20.hs +++ b/2021/day20.hs @@ -30,7 +30,8 @@ next :: Algorithm -> Image -> Image next algo (Img def diff) = Img (newDefault algo def) newDiff where nonDefault = foldr (\(x,y) -> insertManyWith (++) (neighs x y)) M.empty diff neighs x y = map (\i -> ((x-1 + i `mod` 3, y-1 + i `div` 3), [i])) [0..8] - calcNonDef = M.filter (/= newDefault algo def) $ M.map (\ns -> algo A.! binToDec (nonDefToNum ns)) nonDefault + known = M.map (\ns -> algo A.! binToDec (nonDefToNum ns)) nonDefault + calcNonDef = M.filter (/= newDefault algo def) known nonDefToNum ns = map (\i -> if i `elem` ns then not def else def) [0..8] newDiff = M.keys calcNonDef