From f57078c32418c7f6a72439f7ebacd48ccbea93af Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Tue, 21 May 2024 22:10:06 +0100 Subject: [PATCH] 17a starting to work need to not restart jet sequence for each rock, though --- 17/17a.bqn | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 17/17a.bqn diff --git a/17/17a.bqn b/17/17a.bqn new file mode 100644 index 0000000..9ab312d --- /dev/null +++ b/17/17a.bqn @@ -0,0 +1,50 @@ +rocks←⟨ + ["...####.."] + + ["....#...." + "...###..." + "....#...."] + + [".....#..." + ".....#..." + "...###..."] + + ["...#....." + "...#....." + "...#....." + "...#....."] + + ["...##...." + "...##...."] +⟩ +rocks ".#"⊸⊐¨↩ # Convert to boolean array + +Prep←(⊏⟜⟨«˘,»˘⟩)∘("<>"⊸⊐) + +Extend←⟨1,0,0,0,0,0,0,0,1⟩⊸∾ + +Space←{+´2=+˝˘𝕩} + +Main←{𝕊 jets: + arena←⟨1,9⟩⥊1 + { + falling←((≠rocks)|𝕩)⊑rocks + arena Extend⍟((3+≠falling)-(Space arena)) ↩ + ⟨fallen, fallenpos⟩ ← { 𝕊 ⟨falling,fallpos⟩: + fallpos ↩ 1+fallpos + jet←((≠jets)|fallpos)⊑jets + shifted ← Jet falling + obstructed ← ∨´⥊shifted∧(≠shifted)↑fallpos↓arena + falling ↩ obstructed ⊑ ⟨shifted,falling⟩ + •Show ⟨fallpos,falling∨(≠shifted)↑fallpos↓arena⟩ + ⟨falling,fallpos⟩ + } •_while_ { 𝕊 ⟨falling,fallpos⟩: + ¬∨´⥊falling∧(≠falling)↑(1+fallpos)↓arena + } ⟨falling,¯1⟩ + arena↩ {𝕩∨fallen}⌾{((≠fallen)⊸↑)∘(fallenpos⊸↓)} arena + •Show arena⊏".#" + }¨↕10 + @ +} + +•Show Main Prep ⊑•file.Lines ⊑•args -- 2.30.2