feat(sterni/aoc/2022): day05 BQN solution

First input that is genuinely fun to parse in BQN. There surely is a
nice trick for _ApplyCmd, but this works and I'm unable to think today.

Change-Id: Iefccc81f1c1db03f45e31aaf7a1703ac0f91306f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7529
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
This commit is contained in:
sterni 2022-12-05 19:50:58 +01:00 committed by clbot
parent 5a41c4c6aa
commit 736edce338

View file

@ -0,0 +1,20 @@
ReadDec, SplitOn, IsAsciiNum •Import "../../lib.bqn"
rsrc (<"") SplitOn •FLines "../05/input"
stacks {
count '0'-˜' ' (/) rs
spec 0<(-1)(-1)(000)¨1+count
' ' (/)¨˘>spec/¨(-1)rs
}
cmds {011-˜ ReadDec¨ ((´IsAsciiNum)¨/) (<' ') SplitOn 𝕩}¨ rc
ModestTake (<)
_ApplyCmd {
cft 𝕩
m 𝔽 c ModestTake f𝕨
(m)(t) (c)(f)𝕨
}
•Out "day05.1: "¨stacks _ApplyCmd˜´ cmds
•Out "day05.2: "¨stacks _ApplyCmd˜´ cmds