From: Ben Harris Date: Sat, 25 May 2024 22:35:24 +0000 (+0100) Subject: 17b finally done X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=478a42415e0c718dc4154a06f325d345053bb48b;p=aoc-2022.git 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. --- 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) }