From: Neil Smith Date: Thu, 29 Dec 2022 16:19:16 +0000 (+0000) Subject: Tidying X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=74302040c3188f5306aee7b438094f11652a11f8;p=advent-of-code-22.git Tidying --- diff --git a/advent15/Main.hs b/advent15/Main.hs index 097cf6b..664e47d 100644 --- a/advent15/Main.hs +++ b/advent15/Main.hs @@ -52,29 +52,20 @@ searchRange = ((V2 0 0), (V2 4000000 4000000)) part1, part2 :: [Sensor] -> Region -> Int part1 sensors coverage = sum (fmap countForbidden rowChunks `using` (parList rseq)) - where -- coverage = mconcat $ fmap nearby $ sortOn Down sensors - rowCoords = range ( (V2 (globalMinX sensors) thisY) + where rowCoords = range ( (V2 (globalMinX sensors) thisY) , (V2 (globalMaxX sensors) thisY) ) rowChunks = chunksOf 1000 rowCoords occupied = concatMap (\(Sensor s b) -> [s, b]) sensors - -- forbidden = (filter (\p -> p `notElem` occupied) $ filter (getRegion coverage) rowCoords) `using` (parList rpar) - -- forbidden = (fmap (\p -> (getRegion coverage p, p)) rowCoords) `using` (parList rdeepseq) countForbidden positions = length $ filter (\p -> p `notElem` occupied) $ filter (getRegion coverage) positions part2 sensors coverage = x * 4000000 + y - where -- coverage = mconcat $ fmap nearby $ sortOn Down sensors - boundaries = fmap (filter (inRange searchRange)) + where boundaries = fmap (filter (inRange searchRange)) $ fmap justOutside sensors - -- holes = (fmap (filter (not . (getRegion coverage))) boundaries) `using` (parList rpar) holes = fmap (filter (not . (getRegion coverage))) boundaries `using` (parList rseq) - -- holes = (fmap (filter (not . (getRegion coverage))) boundaries) `using` (parList rpar) - -- holes = withStrategy (parList rpar) (fmap (filter (not . (getRegion coverage))) boundaries) - -- holes = using (fmap (filter (not . (getRegion coverage))) boundaries) (parList rpar) - -- holes = parMap rpar (filter (not . (getRegion coverage))) boundaries V2 x y = head $ concat holes