blob: bca18c1f63c236fcfa354ed1d644a1ab0ff13073 (
plain) (
tree)
|
|
⟨ReadDec, SplitOn, IsAsciiNum⟩ ← •Import "../../lib.bqn"
rs‿rc ← (<"") SplitOn •FLines "../05/input"
stacks ← {
count ← '0'-˜⊑⌽' ' (≠/⊢) ⊑⌽rs
spec ← 0<(-1)↓(-1)⌽∾(∾⟜0‿0‿0)¨1+↕count
' ' (≠/⊢)¨⥊⋈˘⍉>spec⊸/¨(-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
|