From: Ben Harris Date: Mon, 27 May 2024 10:00:03 +0000 (+0100) Subject: 19a: this approach almost works X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=f0a1fe16c3aaaebc962ebdab380bafd0e0edb6c3;p=aoc-2022.git 19a: this approach almost works But not close enough to continue with it. --- diff --git a/19/19a.bqn b/19/19a.bqn new file mode 100644 index 0000000..1b8b267 --- /dev/null +++ b/19/19a.bqn @@ -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⟩⟩