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.

  • @swlabr
    link
    English
    2
    edit-2
    9 months ago
    16

    So, as I’ve been doing the AoC things, I’ve been creating small libraries of convenience functions to reuse, hopefully. This time, I reused some things I wrote for problem 10, which was vindicating.

    a. was a fun coding exercise. Not much more to say.

    b. I lucked out by making a recursive traversal function for a), which let me specify the entry and direction of where my traversal would start. Besides that, similar to a., this was a fun coding exercise. I was surprised that my code (which just ran the function from a) on every edge tile) It only took 2s to run; I thought I might need to memoize some of the results.

    • @zogwarg
      link
      English
      29 months ago
      16 a,b

      Neat!

      In my case it was a lot more of headbanging, the traverse function i wrote for part a was way to slow, since JQ isn’t happy with loop-heavy assignments (if not buried within C-implemented builtins). Part a completed in ~2seconds, which was never going to do (in hindsight it would have taken me less time to simply let it run slowly), I had to optimize it so that the beams don’t step one square at a time, but shoot straight to any obstacle.

      It took me waaaay too long to troubleshoot it into something that actually worked. I’m sure there’s a compact implementation out there, but my part b ended up looking very meaty (and still took ~30s to run): https://github.com/zogwarg/advent-of-code/blob/main/2023/jq/16-b.jq

      • @swlabr
        link
        English
        39 months ago

        That’s such a different programming paradigm than I’m used to!