advent-of-code/2023/day19/day19.bqn
2024-11-12 21:46:18 +01:00

25 lines
1.1 KiB
BQN
Raw 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.

Split•Import"../bqn-libs/strings.bqn"
wsps01¨(+`¨)•FLines"input"
p•ParseFloat¨¨2¨¨","Split¨¯1¨1¨ps
idsprogs{":"Split¨¨","Split¨¯1¨𝕩}(1)<˘>"{"Split¨ws
ParseProg{𝕊tr: (("<>"1t)<>)(•ParseFloat 2t)(("xmas"𝕩)),r ; 𝕩}
wParseProg¨¨progs
Apply{n𝕊r: r ; fr𝕩 (F 𝕨)𝕨𝕊(1𝕩),r}
Sel{𝕊"A": "A" ; 𝕊"R": "R" ;(/𝕩¨ids)w}
Run{𝕩(ApplySel¨)•_while_{¬´¨"AR"¨𝕩}(𝕩)<"in"}
•Show +´('A'=Run p)/p
lsns<˘>(((•ParseFloat 2)+('>'=1)))¨¯1¨¨¨progs
b1¨¨ns¨¨"xmas"ls
db1¨+`¨4001¨b
c0
{
c+(×´𝕩¨db)×"A"Run𝕩¨b
i+´`0=𝕩
(i¯1+¨b)˙(i) -1(i) 𝕩
}•_while_{𝕩40}¯1+¨b
•Show c+("A"Run¨b)××´¨db