about summary refs log tree commit diff
path: root/users/sterni/exercises/aoc
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2022-12-01T12·41+0100
committersterni <sternenseemann@systemli.org>2022-12-01T23·38+0000
commit6abea467e2023a63e3413317c90409d11175f9a9 (patch)
treee16d1aaf1d8765b6c20ed27455a27ee07f6e02f9 /users/sterni/exercises/aoc
parent6fd9792240fe3797477e31a209743440718932aa (diff)
chore(sterni/exercises/aoc): split out utils into a library of sorts r/5362
Change-Id: Id2bb764fcdcd4b345eed6a98e0d67fcb18fc1353
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7488
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'users/sterni/exercises/aoc')
-rwxr-xr-xusers/sterni/exercises/aoc/2021/solutions.bqn9
-rw-r--r--users/sterni/exercises/aoc/lib.bqn8
2 files changed, 9 insertions, 8 deletions
diff --git a/users/sterni/exercises/aoc/2021/solutions.bqn b/users/sterni/exercises/aoc/2021/solutions.bqn
index 4cedb567f9aa..f7247cadf280 100755
--- a/users/sterni/exercises/aoc/2021/solutions.bqn
+++ b/users/sterni/exercises/aoc/2021/solutions.bqn
@@ -4,17 +4,10 @@
 # Utilities
 #
 
-IsAsciiNum ← ('0'⊸≤∧≤⟜'9')
-
-ReadInt ← {(𝕨⊸×+⊣)´∘⌽-⟜'0'𝕩} # stolen from leah2
-ReadDec ← 10⊸ReadInt
+⟨IsAsciiNum,ReadInt,ReadDec,SplitOn,_fix⟩ ← •Import •path∾"/../lib.bqn"
 
 ReadInput ← {•file.Lines ∾ •path‿"/input/day"‿(•Fmt 𝕩)}
 
-SplitOn ← ((⊢ (-1˙)⍟⊣¨ +`∘(1⊸»<⊢))∘(≡¨)⊔⊢)
-
-_fix ← {𝕩 𝕊∘⊢⍟≢ 𝔽 𝕩}
-
 #
 # 2021-12-01
 #
diff --git a/users/sterni/exercises/aoc/lib.bqn b/users/sterni/exercises/aoc/lib.bqn
new file mode 100644
index 000000000000..025102b7760b
--- /dev/null
+++ b/users/sterni/exercises/aoc/lib.bqn
@@ -0,0 +1,8 @@
+IsAsciiNum ⇐ ('0'⊸≤∧≤⟜'9')
+
+ReadInt ⇐ {(𝕨⊸×+⊣)´∘⌽-⟜'0'𝕩} # stolen from leah2
+ReadDec ⇐ 10⊸ReadInt
+
+SplitOn ⇐ ((⊢ (-1˙)⍟⊣¨ +`∘(1⊸»<⊢))∘(≡¨)⊔⊢)
+
+_fix ⇐ {𝕩 𝕊∘⊢⍟≢ 𝔽 𝕩}