advent-of-code/2024/day03/day03.bqn
2024-12-03 17:57:49 +01:00

18 lines
703 B
BQN
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

in•FChars"input"
Digits'0''9'
P1{𝕊in:
s000"mul("in # start pattern
dDigits in # digits
c','=in # separator comma
e')'=in # end pattern
x(2×s)+d+(3×c)+2×e # id for each part of the pattern to match
pats{2,𝕩1,3,𝕨1,2}˜1+5 # patterns to look for, with numbers of up to 5 digits
idxs/¨x¨pats # index for each pattern
+´×´¨pats{𝕨{•ParseFloat¨01¨(','=)(+`)(¯2+𝕨)(1+𝕩)in}¨𝕩}¨idxs
}
•Show P1 in
Split{(+`((𝕨)0)𝕨𝕩)𝕩}
•Show +´P1¨¨1¨"do()"Split¨"don't()"Split "do()"in