2022-12-05 19:50:58 +01:00
|
|
|
|
⟨ReadDec, SplitOn, IsAsciiNum⟩ ← •Import "../../lib.bqn"
|
|
|
|
|
rs‿rc ← (<"") SplitOn •FLines "../05/input"
|
|
|
|
|
|
|
|
|
|
stacks ← {
|
|
|
|
|
count ← '0'-˜⊑⌽' ' (≠/⊢) ⊑⌽rs
|
2022-12-10 21:35:26 +01:00
|
|
|
|
' ' (≠/⊢)¨<˘ (count×4) ((»∘(0⊸=)∘(4⊸|)∘↕⊣)/↑) ⍉> (-1)↓rs
|
2022-12-05 19:50:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cmds ← {0‿1‿1-˜ ReadDec¨ ((∧´IsAsciiNum)¨/⊢) (<' ') SplitOn 𝕩}¨ rc
|
|
|
|
|
|
|
|
|
|
_ApplyCmd ← {
|
2022-12-05 22:40:16 +01:00
|
|
|
|
s Fn _self c‿f‿t :
|
|
|
|
|
m‿k ← 2↑ c ((≤⟜(↕≠))⊔⊢) f⊑s
|
|
|
|
|
(Fn m)⊸∾⌾(t⊸⊑) k˙⌾(f⊸⊑) s
|
2022-12-05 19:50:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
•Out "day05.1: "∾⊑¨stacks ⌽_ApplyCmd˜´ ⌽ cmds
|
|
|
|
|
•Out "day05.2: "∾⊑¨stacks ⊢_ApplyCmd˜´ ⌽ cmds
|