2024 day 3 bqn

This commit is contained in:
Dimitri Lozeve 2024-12-03 17:57:49 +01:00
parent 828d855d6d
commit 6b4cc3984a

18
2024/day03/day03.bqn Normal file
View file

@ -0,0 +1,18 @@
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