18
The official awful.systems Advent of Code 2023 thread
(awful.systems)
a community for posting cool tech news you don’t want to sneer at
non-awfulness of tech is not required or else we wouldn’t have any posts
Day 11: Cosmic Expansion
https://adventofcode.com/2023/day/11
discussion
After yesterday' fiddle-fest we are back with a straight-forward puzzle. Today we get the return of Manhattan distance, an AoC fav, but this time not spelled out to fool the crafty LLMs.
I made the initial decision not to "move" the galaxies in the initial map, but instead to store an offset that was increased whenever an empty row or column preceding the object was detected. This turned out to make part 2 really easy once I figured out the off-by-one error.
discussion
In retrospect that would have been far better for runtime, my dist function ended up being a tad expensive.I substituted the rows/columns, with multiplication by the expansion rate if they were all numbers. And then for each galaxy pair do a running sum by going “down” the “right” and adding the distance for each row and column crossed.
https://github.com/zogwarg/advent-of-code/blob/main/2023/jq/11-b.jq
transpose
is nice to have in that approach.