feat(sterni/aoc/2022): day21.1 BQN solution

This one is not finished yet, but needs to move of this laptop by ways
of git.

Change-Id: I2c8c0a7b581a654f7cfab92dd21ced82a14c5f42
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7616
Tested-by: BuildkiteCI
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
sterni 2022-12-23 15:28:48 +01:00 committed by clbot
parent 9008fb0839
commit 835ea6ca7d
2 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,25 @@
ImportBqnLibs, IsAsciiNum, ReadDec •Import "../../lib.bqn"
ReplaceAll, Split ImportBqnLibs "strings.bqn"
i ": "Split¨ •FLines "input"
ReplaceInts {
𝕊 𝕩: 𝕊´ 2(¬(´IsAsciiNum)¨) 𝕩;
# TODO: Efficient replace on tokens
is 𝕊 es: (((•Fmt(0•Type))¨(1) <˘>is)ReplaceAll(1))¨ es
}
c 0
CanEval (IsAsciiNum"+-/* ")
Eval {
asb " " Split 𝕩
f +-×÷˜"+-*/"s
a FReadDec b
}
EvalExprs {
pe 2((´CanEval)¨) 𝕩
ev (Eval())¨ e
c +1
((¨ev)˜<"root")EvalExprs(ReplaceIntsp),1 ev
}
•Show EvalExprs ReplaceInts i

View file

@ -1,4 +1,5 @@
IsAsciiNum ('0''9')
IsAlpha (('a''z')('A''Z'))
# based on leah2's function
ReadInt {