diff options
author | sterni <sternenseemann@systemli.org> | 2022-12-10T20·24+0100 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2022-12-10T20·29+0000 |
commit | c381fa64cf9d375290c76436faf1078bc8d81ff7 (patch) | |
tree | 8a0844d0fa3f729729485fa56fea7cbd09331c5d /users/sterni/exercises/aoc/lib.bqn | |
parent | 42a4f1487899b9a23db462d048d22b138957b40c (diff) |
feat(sterni/aoc/2022): day10 BQN solution r/5403
I cheated a bit to skip implementing multi cycle instructions. The VM is pretty much a normal tail recursive function, but working with scalars in BQN is on brand-ish. Array programming helps again when drawing the picture on screen. Change-Id: I2562c862e228f633c5fad09e503529c6e0785112 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7556 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'users/sterni/exercises/aoc/lib.bqn')
-rw-r--r-- | users/sterni/exercises/aoc/lib.bqn | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/users/sterni/exercises/aoc/lib.bqn b/users/sterni/exercises/aoc/lib.bqn index 636eeace78d2..172343b41979 100644 --- a/users/sterni/exercises/aoc/lib.bqn +++ b/users/sterni/exercises/aoc/lib.bqn @@ -1,6 +1,10 @@ IsAsciiNum ⇐ ('0'⊸≤∧≤⟜'9') -ReadInt ⇐ {(𝕨⊸×+⊣)´∘⌽-⟜'0'𝕩} # stolen from leah2 +# based on leah2's function +ReadInt ⇐ { + 𝕨 𝕊 𝕩: '-'=⊑𝕩? -𝕨 𝕊 1↓𝕩; + 𝕨 𝕊 𝕩: (𝕨⊸×+⊣)´∘⌽-⟜'0'𝕩 +} ReadDec ⇐ 10⊸ReadInt SplitOn ⇐ ((⊢ (-1˙)⍟⊣¨ +`∘(1⊸»<⊢))∘(≡¨)⊔⊢) |