projects
/
advent-of-code-22.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
ef83546
)
Tidying
author
Neil Smith
<NeilNjae@users.noreply.github.com>
Thu, 29 Dec 2022 16:19:16 +0000
(16:19 +0000)
committer
Neil Smith
<NeilNjae@users.noreply.github.com>
Thu, 29 Dec 2022 16:19:16 +0000
(16:19 +0000)
advent15/Main.hs
patch
|
blob
|
history
diff --git
a/advent15/Main.hs
b/advent15/Main.hs
index 097cf6b6850748d1a7a93294771937e4f94bb8f7..664e47d0ab4bb73a4b44cb135d96ebd35400aa13 100644
(file)
--- 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))
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
, (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
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
$ 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 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
V2 x y = head $ concat holes