chore(sterni/exercises/aoc): split out utils into a library of sorts
Change-Id: Id2bb764fcdcd4b345eed6a98e0d67fcb18fc1353 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7488 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
6fd9792240
commit
6abea467e2
2 changed files with 9 additions and 8 deletions
|
@ -4,17 +4,10 @@
|
||||||
# Utilities
|
# Utilities
|
||||||
#
|
#
|
||||||
|
|
||||||
IsAsciiNum ← ('0'⊸≤∧≤⟜'9')
|
⟨IsAsciiNum,ReadInt,ReadDec,SplitOn,_fix⟩ ← •Import •path∾"/../lib.bqn"
|
||||||
|
|
||||||
ReadInt ← {(𝕨⊸×+⊣)´∘⌽-⟜'0'𝕩} # stolen from leah2
|
|
||||||
ReadDec ← 10⊸ReadInt
|
|
||||||
|
|
||||||
ReadInput ← {•file.Lines ∾ •path‿"/input/day"‿(•Fmt 𝕩)}
|
ReadInput ← {•file.Lines ∾ •path‿"/input/day"‿(•Fmt 𝕩)}
|
||||||
|
|
||||||
SplitOn ← ((⊢ (-1˙)⍟⊣¨ +`∘(1⊸»<⊢))∘(≡¨)⊔⊢)
|
|
||||||
|
|
||||||
_fix ← {𝕩 𝕊∘⊢⍟≢ 𝔽 𝕩}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# 2021-12-01
|
# 2021-12-01
|
||||||
#
|
#
|
||||||
|
|
8
users/sterni/exercises/aoc/lib.bqn
Normal file
8
users/sterni/exercises/aoc/lib.bqn
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
IsAsciiNum ⇐ ('0'⊸≤∧≤⟜'9')
|
||||||
|
|
||||||
|
ReadInt ⇐ {(𝕨⊸×+⊣)´∘⌽-⟜'0'𝕩} # stolen from leah2
|
||||||
|
ReadDec ⇐ 10⊸ReadInt
|
||||||
|
|
||||||
|
SplitOn ⇐ ((⊢ (-1˙)⍟⊣¨ +`∘(1⊸»<⊢))∘(≡¨)⊔⊢)
|
||||||
|
|
||||||
|
_fix ⇐ {𝕩 𝕊∘⊢⍟≢ 𝔽 𝕩}
|
Loading…
Reference in a new issue