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:
3952084
)
09a: successfully tracing path using fold
author
Ben Harris
<bjh21@bjh21.me.uk>
Thu, 9 May 2024 08:25:58 +0000
(09:25 +0100)
committer
Ben Harris
<bjh21@bjh21.me.uk>
Thu, 9 May 2024 08:25:58 +0000
(09:25 +0100)
09/09a.bqn
[new file with mode: 0644]
patch
|
blob
diff --git a/09/09a.bqn
b/09/09a.bqn
new file mode 100644
(file)
index 0000000..
1c46524
--- /dev/null
+++ b/
09/09a.bqn
@@ -0,0
+1,15
@@
+
+Prep←{
+ directions←⍉['U'‿⟨0,1⟩,'D'‿⟨0,¯1⟩,'L'‿⟨¯1,0⟩,'R'‿⟨1,0⟩]
+ dirs←((⊏directions)⊐⊏⍉𝕩)⊏(1⊏directions)
+ dists←•ParseFloat˘2↓˘𝕩
+ dists/dirs
+}
+
+Step←{m𝕊⟨h,t⟩:h+↩m,t+↩(×h-t)×(∨´1<|h-t),•Show⟨h,t⟩}
+
+Main←{
+ ⟨⟨0,0⟩,⟨0,0⟩⟩Step´⌽𝕩
+}
+
+•Show Main Prep>•file.Lines ⊑•args