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

28 lines
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.

mngrid'0'-˜>•FLines"input"
dirs-01
Inbounds´(00<mn)
Step{ab𝕊qvdists:
u2q
d{𝕊000: 99 ; (2𝕩)dirs}q
ns(Inbounds¨¨)/ u+¨¨{𝕩ר¨((1+b)¨a+1+b-a)}¨dirs
ns((|d)¨|-u¨¨ns)/ns
nsns¨¨¨(dirs<)¨u-˜¨¨ns
ns(¬(¨ns)v)/ns
newdistsdists (((q)dists)++´¨grid¨2¨¨ns)((¨ns))dists
changedns((newdists<dists)¨¨ns) / ns
newq(newdists) (¨changedns)1q
newv1((q))v
newqnewvnewdists
}
Target´ ((n-1) (m-1)) #(m‿n-1)⊑⌊˝⎉1
q000
vmn40
ub1e4
dists0˙¨((00¨4)) mn4ub
··d113 Step•_while_{ub=Target 2𝕩} qvdists
•Show Target d1
··d2410 Step•_while_{ub=Target 2𝕩} qvdists
•Show Target d2