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:
2470b4e
)
13a: most of the list parser done
author
Ben Harris
<bjh21@bjh21.me.uk>
Mon, 13 May 2024 13:33:52 +0000
(14:33 +0100)
committer
Ben Harris
<bjh21@bjh21.me.uk>
Mon, 13 May 2024 13:33:52 +0000
(14:33 +0100)
13/13a.bqn
[new file with mode: 0644]
patch
|
blob
diff --git a/13/13a.bqn
b/13/13a.bqn
new file mode 100644
(file)
index 0000000..
6a1c6b1
--- /dev/null
+++ b/
13/13a.bqn
@@ -0,0
+1,20
@@
+Split←{
+ blocknums ← +`𝕨
+ # Set entries in blocknums to -1 when they correspond with delimiters.
+ blocknums ↩ (¯1¨)⌾(𝕨⊸/) blocknums
+ blocknums⊔𝕩
+}
+
+Prep←{
+ {•Show 𝕩 ⋄ •Show ParseVal 𝕩}¨¨(""⊸≡¨𝕩)Split𝕩
+}
+
+ParseList←{𝕊in:
+ in↩1↓¯1↓in
+ depth←+`('['=in)-(']'=in)
+ ParseVal¨ ((','=in)∧(depth=0)) Split in
+}
+
+ParseVal←{'['=⊑𝕩}◶⟨•ParseFloat,ParseList⟩
+
+•Show Prep •file.Lines ⊑•args