copy pasting the rules from last year’s thread:

Rules: no spoilers.

The other rules are made up aswe 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.systems
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    17 days ago
    Re: day 7 parts 1 and 2

    same here, I was dicking around with combinatorics to get all combos of plus and multiply but realized before I got to the end it was gonna take too long. Then I figured that a DFS was the way to go.

    I tried to optimize a bit by exiting early if the cumulative result became too large, but for some reason that gave me incorrect (too low) answers. Part 2 runs in around 1 min anyway.

    https://github.com/gustafe/aoc2024/blob/main/d07-Bridge-Repair.pl

    • swlabr@awful.systems
      link
      fedilink
      English
      arrow-up
      2
      ·
      17 days ago
      re: branch cutting

      IDK if this is what your issue was, but one thing I ran into was that if you do something like if (current_total >= target) prune(), this can be problematic because if the tail end of the data is 0s and 1s, you exit too early. Basically I would prune strictly when the current total > target.