From 478a42415e0c718dc4154a06f325d345053bb48b Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sat, 25 May 2024 23:35:24 +0100 Subject: [PATCH] 17b finally done I got confused and forgot that jets didn't reset for each rock. Once that was fixed it was only a bit slow. --- 17/17b.bqn | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/17/17b.bqn b/17/17b.bqn index 2be224b..ebce535 100644 --- a/17/17b.bqn +++ b/17/17b.bqn @@ -55,17 +55,23 @@ Main←{𝕊 jets: falling←thisrock⊑rocks arena Extend⍟((3+≠falling)-(Space arena)) ↩ thiscast←Cast arena - •Show ⟨thiscast,thisrock⟩ + nowheight←(≠arena)-(1+Space arena) + #•Show ⟨thiscast⊏".#",thisrock⟩ + #•Show rockcount {𝕤 - ⟨wasrockcount,washeight⟩←castlog.Get⟨thiscast,thisrock⟩ + ⟨wasrockcount,washeight⟩←castlog.Get⟨thiscast,thisrock,jetpos⟩ + •Show ⟨"Tick", wasrockcount⟩ {𝕤 •Show "Got it!" - nowheight←(≠arena)-(1+Space arena) + •Show ⟨nowheight,washeight, rockcount,wasrockcount⟩ + •Show arena⊏".#" + •Show thiscast⊏".#" •Show nowheight+(nowheight-washeight)×(target-rockcount)÷(rockcount-wasrockcount) •Exit 0 }⍟(0=(rockcount-wasrockcount)|(target-rockcount)) @ - }⍟(castlog.Has ⟨thiscast,thisrock⟩) @ - ⟨thiscast,thisrock⟩ castlog.Set ⟨rockcount,(≠arena)-(1+Space arena)⟩ + }⍟(castlog.Has ⟨thiscast,thisrock,jetpos⟩) @ + ⟨thiscast,thisrock,jetpos⟩ castlog.Set ⟨rockcount,nowheight⟩ + #path←⟨⟩ ⟨fallen, fallenpos⟩ ← { 𝕊 ⟨falling,fallpos⟩: fallpos ↩ 1+fallpos jet←jetpos⊑jets @@ -74,15 +80,17 @@ Main←{𝕊 jets: obstructed ← ∨´⥊shifted∧(≠shifted)↑fallpos↓arena falling ↩ obstructed ⊑ ⟨shifted,falling⟩ #•Show ⟨fallpos,falling∨(≠shifted)↑fallpos↓arena⟩ + #path∾↩⟨falling∨(≠shifted)↑fallpos↓arena⟩ ⟨falling,fallpos⟩ } •_while_ { 𝕊 ⟨falling,fallpos⟩: ¬∨´⥊falling∧(≠falling)↑(1+fallpos)↓arena } ⟨falling,¯1⟩ + #•Show ⊏⟜".#"¨path arena↩ {𝕩∨fallen}⌾{((≠fallen)⊸↑)∘(fallenpos⊸↓)} arena thisrock↩(≠rocks)|1+thisrock rockcount+↩1 - •Show arena⊏".#" - }¨↕100 + #•Show arena⊏".#" + }¨↕10000 (≠arena)-(1+Space arena) } -- 2.30.2