From: Ben Harris Date: Sun, 5 May 2024 15:26:05 +0000 (+0100) Subject: 05: simpler Prep X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=a79252ee4a0a2b54f1a0bccb6f078a52a22fefdd;p=aoc-2022.git 05: simpler Prep --- diff --git a/05/05a.bqn b/05/05a.bqn index 0eda860..d84ea03 100644 --- a/05/05a.bqn +++ b/05/05a.bqn @@ -13,9 +13,9 @@ Prep1Proc←{ # Prepare one step of procedure Prep←{ ⟨rawmap, rawproc⟩←(""⊸≡¨𝕩)Split𝕩 - map0←⍉>¯1↓rawmap # Drop last line and transpose - map1←(1=4|↕≠map0)/map0 # Extract crate letters from chaff - map←⟨""⟩∾{(𝕩≠' ')/𝕩}¨<˘map1 # Convert to a 0-based list of strings + map0←⍉>¯1↓rawmap # Drop last line and transpose + map1←(1=4|↕≠map0)/map0 # Extract crate letters from chaff + map←⟨""⟩∾{<(𝕩≠' ')/𝕩}˘map1 # Convert to a 0-based list of strings proc←∾Prep1Proc¨rawproc ⟨map, proc⟩ } diff --git a/05/05b.bqn b/05/05b.bqn index ad2c9a4..d219cc2 100644 --- a/05/05b.bqn +++ b/05/05b.bqn @@ -11,9 +11,9 @@ Prep1Proc←{ # Prepare one step of procedure Prep←{ ⟨rawmap, rawproc⟩←(""⊸≡¨𝕩)Split𝕩 - map0←⍉>¯1↓rawmap # Drop last line and transpose - map1←(1=4|↕≠map0)/map0 # Extract crate letters from chaff - map←⟨""⟩∾{(𝕩≠' ')/𝕩}¨<˘map1 # Convert to a 0-based list of strings + map0←⍉>¯1↓rawmap # Drop last line and transpose + map1←(1=4|↕≠map0)/map0 # Extract crate letters from chaff + map←⟨""⟩∾{<(𝕩≠' ')/𝕩}˘map1 # Convert to a 0-based list of strings proc←>Prep1Proc¨rawproc ⟨map, proc⟩ }