chiark / gitweb /
23a: all proposals generated
authorBen Harris <bjh21@bjh21.me.uk>
Thu, 6 Jun 2024 22:49:00 +0000 (23:49 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Thu, 6 Jun 2024 22:49:00 +0000 (23:49 +0100)
But how to merge them?

23/23a.bqn

index 4c759dc1505500a22abd7f84f567ca9ffc782bf0..142ad49a5f87aeb9d65f74c5cc6b2b44fa5571a5 100644 (file)
@@ -1,5 +1,21 @@
 Prep←".#"⊸⊐∘>
 
-Main←⊢
+# Propose moving north if possible.
+ProposeN←{ ((1≠+´⥊𝕩)∧(0=+´⊏𝕩))/⟨[0‿1‿0,0‿0‿0,0‿0‿0]⟩ }
+
+Propose←{𝕊in: # Given a map of local area, say where Elf in centre will go.
+  ⊑ (∾{𝕏⁼¨ ProposeN 𝕏 in}¨{⌽∘⍉⍟𝕩}¨⟨0,2,3,1⟩) ∾ ⟨[0‿0‿0,0‿1‿0,0‿0‿0]⟩
+}
+
+# Same but propose empty array if there is no Elf.
+ProposeOr←{ (⟨1,1⟩⊑𝕩)∧Propose 𝕩 }
+
+Round←{𝕊map:
+  •Show map
+  ⟨h,w⟩←≢map ⋄ map↩»˘»(2+w)↑˘(2+h)↑map # Pad the map so windows work.
+  ⟨2,3,0,1⟩⍉ProposeOr⎉2⟨3,3⟩↕map
+}
+
+Main←Round⍟1
 
 •Show Main Prep •file.Lines ⊑•args