diff options
author | sterni <sternenseemann@systemli.org> | 2022-12-05T21·40+0100 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2022-12-05T21·45+0000 |
commit | 3f2172556a8b83abe5b6f760fabae5d766a50a05 (patch) | |
tree | 988a8775f631ba77b12b1df7ebac99fa16dfa175 /users/sterni/exercises | |
parent | 736edce3381c88feb7751427b6cae13c84b57b70 (diff) |
refactor(sterni/aoc/2022/05): improve _ApplyCmd r/5393
* take advantage of block header for destructuring * instead of ModestTake we can split the stack we are picking from into what we need to move and what to keep, saving us from having to repeat ourselves. * remove some unnecessary parens Change-Id: I1b81a93a27d14dcbb6bdd109e862a356f611aca9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7530 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'users/sterni/exercises')
-rw-r--r-- | users/sterni/exercises/aoc/2022/05/5.bqn | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/users/sterni/exercises/aoc/2022/05/5.bqn b/users/sterni/exercises/aoc/2022/05/5.bqn index e65975db9476..bca18c1f63c2 100644 --- a/users/sterni/exercises/aoc/2022/05/5.bqn +++ b/users/sterni/exercises/aoc/2022/05/5.bqn @@ -9,11 +9,10 @@ stacks ← { cmds ← {0‿1‿1-˜ ReadDec¨ ((∧´IsAsciiNum)¨/⊢) (<' ') SplitOn 𝕩}¨ rc -ModestTake ← ↑⍟(<⟜≠) _ApplyCmd ← { - c‿f‿t ← 𝕩 - m ← 𝔽 c ModestTake f⊑𝕨 - (m⊸∾)⌾(t⊸⊑) (c⊸↓)⌾(f⊸⊑)𝕨 + s Fn _self c‿f‿t : + m‿k ← 2↑ c ((≤⟜(↕≠))⊔⊢) f⊑s + (Fn m)⊸∾⌾(t⊸⊑) k˙⌾(f⊸⊑) s } •Out "day05.1: "∾⊑¨stacks ⌽_ApplyCmd˜´ ⌽ cmds |