From 905d12dbf25bbf71c2c9ba5ecb95224aa604217c Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Thu, 6 Jun 2024 23:49:00 +0100 Subject: [PATCH] 23a: all proposals generated But how to merge them? --- 23/23a.bqn | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/23/23a.bqn b/23/23a.bqn index 4c759dc..142ad49 100644 --- a/23/23a.bqn +++ b/23/23a.bqn @@ -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 -- 2.30.2