From: Ben Harris Date: Thu, 9 May 2024 12:49:19 +0000 (+0100) Subject: 09b done X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=71de27500d760395f106375f847d5718526be501;p=aoc-2022.git 09b done --- diff --git a/09/09b.bqn b/09/09b.bqn new file mode 100644 index 0000000..f857c80 --- /dev/null +++ b/09/09b.bqn @@ -0,0 +1,16 @@ +Prep←{ + directions←⍉['U'‿⟨0,1⟩,'D'‿⟨0,¯1⟩,'L'‿⟨¯1,0⟩,'R'‿⟨1,0⟩] + dirs←((⊏directions)⊐⊑¨𝕩)⊏(1⊏directions) + dists←{•ParseFloat 2↓𝕩}¨𝕩 + dists/dirs +} + +StepH←{h𝕊m:h+m} +StepT←{t𝕊h:t+(×h-t)×(∨´1<|h-t)} + +Main←{ + start←<⟨0,0⟩ + +´∊ (start⊸(StepT`))⍟9 start StepH` 𝕩 +} + +•Show Main Prep •file.Lines ⊑•args