X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=advent11%2FMain.hs;fp=advent11%2FMain.hs;h=cfdbe0ea871162939205b963a3eb5f9c018ea9d2;hb=d2427d370c43ca58800f203a6b7dcbd5a815c5a8;hp=283060d7c8a7bf470588aa87d9dc9a3580099805;hpb=bd05a32800503977f2641d1970538836790ce748;p=advent-of-code-23.git diff --git a/advent11/Main.hs b/advent11/Main.hs index 283060d..cfdbe0e 100644 --- a/advent11/Main.hs +++ b/advent11/Main.hs @@ -1,4 +1,4 @@ --- Writeup at https://work.njae.me.uk/2023/12/10/advent-of-code-2023-day-10/ +-- Writeup at https://work.njae.me.uk/2023/12/11/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