From a7d9b5be995e48fb89d7de5e379aed09718aa136 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sun, 5 May 2024 11:28:33 +0100 Subject: [PATCH] Prep for 05a --- 05/05a.bqn | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 05/05a.bqn diff --git a/05/05a.bqn b/05/05a.bqn new file mode 100644 index 0000000..f144cf1 --- /dev/null +++ b/05/05a.bqn @@ -0,0 +1,22 @@ +Split←{ + blocknums ← +`𝕨 + # Set entries in blocknums to -1 when they correspond with delimiters. + blocknums ↩ (¯1¨)⌾(𝕨⊸/) blocknums + blocknums⊔𝕩 +} + +Prep1Proc←{ # Prepare one step of procedure + # Converts "move 3 from 1 to 3" into [⟨1,3⟩,⟨1,3⟩,⟨1,3⟩]. + ⟨n,f,t⟩←•ParseFloat¨⟨1,3,5⟩⊏(' '=𝕩)Split𝕩 + ⟨n⟩/[⟨f,t⟩] +} + +Prep←{ + ⟨rawmap, rawproc⟩←(""⊸≡¨𝕩)Split𝕩 + map0←{(𝕩≠' ')/𝕩}¨<˘⍉⌽>¯1↓rawmap + map1←⟨""⟩∾(1=4|↕≠map0)/map0 + proc←∾Prep1Proc¨rawproc + ⟨map1, proc⟩ +} + +•Show Prep •file.Lines ⊑•args -- 2.30.2