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.

  • zogwarg@awful.systems
    link
    fedilink
    English
    arrow-up
    2
    ·
    20 days ago

    Day 3 well suited to JQ

    Part 2
    #!/usr/bin/env jq -n -R -f
    
    reduce (
      inputs |   scan("do\\(\\)|don't\\(\\)|mul\\(\\d+,\\d+\\)")
             | [[scan("(do(n't)?)")[0]], [ scan("\\d+") | tonumber]]
    ) as [[$do], [$a,$b]] (
      { do: true, s: 0 };
        if $do == "do" then .do = true
      elif $do         then .do = false
      elif .do         then .s = .s + $a * $b end
    ) | .s