17e0a74e7b
By taking advantage of filling (ironically) we can avoid creating a spec in an ugly way. Additionally we transpose before parsing which doesn't really make all that much of a difference, though. Change-Id: Ida593138654f8367d666447f2b62013e8ddff01e Reviewed-on: https://cl.tvl.fyi/c/depot/+/7535 Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
18 lines
614 B
BQN
18 lines
614 B
BQN
⟨ReadDec, SplitOn, IsAsciiNum⟩ ← •Import "../../lib.bqn"
|
||
rs‿rc ← (<"") SplitOn •FLines "../05/input"
|
||
|
||
stacks ← {
|
||
count ← '0'-˜⊑⌽' ' (≠/⊢) ⊑⌽rs
|
||
' ' (≠/⊢)¨⥊⋈˘ (count×4) ((»∘(0⊸=)∘(4⊸|)∘↕⊣)/↑) ⍉> (-1)↓rs
|
||
}
|
||
|
||
cmds ← {0‿1‿1-˜ ReadDec¨ ((∧´IsAsciiNum)¨/⊢) (<' ') SplitOn 𝕩}¨ rc
|
||
|
||
_ApplyCmd ← {
|
||
s Fn _self c‿f‿t :
|
||
m‿k ← 2↑ c ((≤⟜(↕≠))⊔⊢) f⊑s
|
||
(Fn m)⊸∾⌾(t⊸⊑) k˙⌾(f⊸⊑) s
|
||
}
|
||
|
||
•Out "day05.1: "∾⊑¨stacks ⌽_ApplyCmd˜´ ⌽ cmds
|
||
•Out "day05.2: "∾⊑¨stacks ⊢_ApplyCmd˜´ ⌽ cmds
|