From 9a503340b2996b6da4b044800dbdc930bf0466ed Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 18 Dec 2020 12:07:18 +0530 Subject: add day18 --- execs/Day17.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'execs/Day17.hs') diff --git a/execs/Day17.hs b/execs/Day17.hs index bb632e0..ccedffe 100644 --- a/execs/Day17.hs +++ b/execs/Day17.hs @@ -2,7 +2,7 @@ module Main where import Control.Monad import Data.Map (Map) -import qualified Data.Map as Map +import qualified Data.Map as M import Data.Maybe import Utils @@ -12,7 +12,7 @@ toBool '#' = True toBool '.' = False gridMap :: String -> Map Pos Bool -gridMap s = Map.fromList +gridMap s = M.fromList [((x,y,0,0), toBool a) | (y, row) <- zip [0..] rows , (x, a) <- zip [0..] row @@ -35,13 +35,13 @@ convert False 3 = True convert _ _ = False doStep :: Map Pos Bool -> Map Pos Bool -doStep m = Map.mapWithKey fn $ m <> Map.fromList [(p, False) | p <- concatMap around (Map.keys m)] +doStep m = M.mapWithKey fn $ m <> M.fromList [(p, False) | p <- concatMap around (M.keys m)] where fn pos v = convert v n - where n = howMany id $ map (fromMaybe False . flip Map.lookup m) $ around pos + where n = howMany id $ map (fromMaybe False . flip M.lookup m) $ around pos main :: IO () main = do n <- readFile "input/17" let grid = gridMap n - print $ Map.size $ Map.filter id (iterate doStep grid !! 6) + print $ M.size $ M.filter id (iterate doStep grid !! 6) -- cgit v1.2.3