From: Ben Harris Date: Thu, 6 Jun 2024 22:49:00 +0000 (+0100) Subject: 23a: all proposals generated X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=905d12dbf25bbf71c2c9ba5ecb95224aa604217c;p=aoc-2022.git 23a: all proposals generated But how to merge them? --- 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