Rules: no spoilers.

The other rules are made up as we go along.

Share code by link to a forge, home page, pastebin (Eric Wastl has one here) or code section in a comment.

  • gerikson@awful.systemsOP
    link
    fedilink
    English
    arrow-up
    4
    ·
    1 year ago

    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.

    • zogwarg@awful.systems
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago
      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.