chiark
/
gitweb
/
~bjharris
/
aoc-2022.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
4986b22
)
09a: split head and tail steps
author
Ben Harris
<bjh21@bjh21.me.uk>
Thu, 9 May 2024 12:34:55 +0000
(13:34 +0100)
committer
Ben Harris
<bjh21@bjh21.me.uk>
Thu, 9 May 2024 12:34:55 +0000
(13:34 +0100)
09/09a.bqn
patch
|
blob
|
history
diff --git
a/09/09a.bqn
b/09/09a.bqn
index 4cb47cce3034644137c2dfb2e093e0ac9746b4eb..9d0161ab4202032e8c67fc83a882834d7503b34e 100644
(file)
--- a/
09/09a.bqn
+++ b/
09/09a.bqn
@@
-2,11
+2,13
@@
Prep←{
directions←⍉['U'‿⟨0,1⟩,'D'‿⟨0,¯1⟩,'L'‿⟨¯1,0⟩,'R'‿⟨1,0⟩]
dirs←((⊏directions)⊐⊑¨𝕩)⊏(1⊏directions)
- dists←
•ParseFloat¨2↓
¨𝕩
+ dists←
{•ParseFloat 2↓𝕩}
¨𝕩
dists/dirs
}
-Step←{⟨h,t⟩𝕊m:h+↩m,t+↩(×h-t)×(∨´1<|h-t),⟨h,t⟩}
+StepH←{h𝕊m:h+m}
+StepT←{t𝕊h:t+(×h-t)×(∨´1<|h-t)}
+Step←{⟨h,t⟩𝕊m:h StepH↩m,t StepT↩h,⟨h,t⟩}
Main←{+´∊1⊑¨ (<⟨⟨0,0⟩,⟨0,0⟩⟩)Step`𝕩}