chiark / gitweb /
17b finally done
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 25 May 2024 22:35:24 +0000 (23:35 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 25 May 2024 22:35:24 +0000 (23:35 +0100)
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

index 2be224b2f9c09f4fe989b31e578de72ab44d84e8..ebce53534b23c6be347571fdedd7b3c339e54709 100644 (file)
@@ -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)
 }