From: Ben Harris Date: Sun, 5 May 2024 10:28:33 +0000 (+0100) Subject: Prep for 05a X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=a7d9b5be995e48fb89d7de5e379aed09718aa136;p=aoc-2022.git Prep for 05a --- 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