From: Ben Harris Date: Sun, 12 May 2024 10:08:51 +0000 (+0100) Subject: 12a done X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=88f7a312ebada09e2e6758298da367d10c2f1813;p=aoc-2022.git 12a done --- diff --git a/12/12a.bqn b/12/12a.bqn new file mode 100644 index 0000000..12a1975 --- /dev/null +++ b/12/12a.bqn @@ -0,0 +1,27 @@ +# From https://mlochbaum.github.io/BQN/doc/control.html +While ← {𝕩•_while_𝕨@}´ + +Prep←{ + start⇐'S'=𝕩 + end⇐'E'=𝕩 + map⇐'~'-˜𝕩+(start×'a'-'S')+(end×'z'-'E') +} + +Main←{𝕊⟨start,end,map⟩: + can_go_n←1≥(»map)-map + can_go_s←1≥(«map)-map + can_go_w←1≥(»˘map)-map + can_go_e←1≥(«˘map)-map + Flow←{ + 𝕩∨(«𝕩∧can_go_n)∨(»𝕩∧can_go_s)∨(«˘𝕩∧can_go_w)∨(»˘𝕩∧can_go_e) + } + now←start + count←0 + While {𝕤,¬∨´⥊(now∧end)}‿{𝕤 + now↩Flow now + count+↩1 + } + count +} + +•Show Main Prep >•file.Lines ⊑•args