From aaa4d1680709d6a5799049159d0ff6c8ba850463 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sun, 12 May 2024 11:41:46 +0100 Subject: [PATCH] =?utf8?q?12:=20Use=20the=20primitive=20=E2=80=A2=5Fwhile?= =?utf8?q?=5F:=20it's=20actually=20easier=20to=20understand?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- 12/12a.bqn | 9 +-------- 12/12b.bqn | 9 +-------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/12/12a.bqn b/12/12a.bqn index 12a1975..f0ebe28 100644 --- a/12/12a.bqn +++ b/12/12a.bqn @@ -1,6 +1,3 @@ -# From https://mlochbaum.github.io/BQN/doc/control.html -While ← {𝕩•_while_𝕨@}´ - Prep←{ start⇐'S'=𝕩 end⇐'E'=𝕩 @@ -15,12 +12,8 @@ Main←{𝕊⟨start,end,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+↩1 ⋄ Flow 𝕩} •_while_ {¬∨´⥊(𝕩∧end)} start count } diff --git a/12/12b.bqn b/12/12b.bqn index 177d917..d92f7c9 100644 --- a/12/12b.bqn +++ b/12/12b.bqn @@ -1,6 +1,3 @@ -# From https://mlochbaum.github.io/BQN/doc/control.html -While ← {𝕩•_while_𝕨@}´ - Prep←{ start⇐'S'=𝕩 end⇐'E'=𝕩 @@ -16,12 +13,8 @@ Main←{𝕊⟨start,end,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+↩1 ⋄ Flow 𝕩} •_while_ {¬∨´⥊(𝕩∧end)} start count } -- 2.30.2