chiark / gitweb /
19a: this approach almost works
authorBen Harris <bjh21@bjh21.me.uk>
Mon, 27 May 2024 10:00:03 +0000 (11:00 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Mon, 27 May 2024 10:00:03 +0000 (11:00 +0100)
But not close enough to continue with it.

19/19a.bqn [new file with mode: 0644]

diff --git a/19/19a.bqn b/19/19a.bqn
new file mode 100644 (file)
index 0000000..1b8b267
--- /dev/null
@@ -0,0 +1,16 @@
+# Material types are ore, clay, obsidian, geode.
+
+# Initially just handle the first blueprint.
+
+robot_costs ← [⟨4,0,0,0⟩,⟨2,0,0,0⟩,⟨3,14,0,0⟩,⟨2,0,7,0⟩]
+
+Search←{
+  𝕊⟨·,stock,·⟩: ∨´0>stock ? ¯∞; # Bankruptcy is undesirable.
+  𝕊⟨0,stock,·⟩: 3⊑stock;
+  𝕊⟨time,stock,robots⟩:
+    •Show ⟨time,stock,robots⟩
+    ⌈´Search¨⟨⟨time-1,stock+robots,robots⟩⟩∾{
+        ⟨time-1,stock+robots-𝕩⊏robot_costs,(1⊸+)⌾(𝕩⊸⊑)robots⟩}¨↕≠robot_costs
+}
+
+•Show Search ⟨5,⟨0,0,0,0⟩,⟨1,0,0,0⟩⟩