projects
/
advent-of-code-23.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
bd05a32
)
Added link to blog
author
Neil Smith
<NeilNjae@users.noreply.github.com>
Mon, 11 Dec 2023 11:14:19 +0000
(11:14 +0000)
committer
Neil Smith
<NeilNjae@users.noreply.github.com>
Mon, 11 Dec 2023 11:14:19 +0000
(11:14 +0000)
advent11/Main.hs
patch
|
blob
|
history
diff --git
a/advent11/Main.hs
b/advent11/Main.hs
index 283060d7c8a7bf470588aa87d9dc9a3580099805..cfdbe0ea871162939205b963a3eb5f9c018ea9d2 100644
(file)
--- a/
advent11/Main.hs
+++ b/
advent11/Main.hs
@@
-1,4
+1,4
@@
--- Writeup at https://work.njae.me.uk/2023/12/1
0/advent-of-code-2023-day-10
/
+-- Writeup at https://work.njae.me.uk/2023/12/1
1/advent-of-code-2023-day-11
/
import AoC
@@
-29,7
+29,8
@@
part2 galaxies = allDistances $ expandGalaxies galaxies (10^6)
allDistances :: Galaxies -> Int
allDistances gs = case S.minView gs of
Nothing -> 0
- Just (g, gs') -> (S.foldl' (addDist g) 0 gs) + allDistances gs'
+ Just (g, gs') -> (S.foldl' (
+ addDist g) 0 gs) + allDistances gs'
where addDist g1 acc g2 = acc + distance g1 g2
distance :: Position -> Position -> Int