diff options
author | Leah Neukirchen <leah@vuxu.org> | 2021-12-25 17:51:49 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2021-12-25 17:51:49 +0100 |
commit | ceb09f9791e37f5c7fc422c9f848de09d58a7337 (patch) | |
tree | 5e4c9a3ab4c4d851ce53e1e008fb6886e0ec4e61 /day24.bqn | |
parent | 01eae09c06e680f5ad9c7845d6ad33bcac458330 (diff) | |
download | adventofcode2021-ceb09f9791e37f5c7fc422c9f848de09d58a7337.tar.gz adventofcode2021-ceb09f9791e37f5c7fc422c9f848de09d58a7337.tar.xz adventofcode2021-ceb09f9791e37f5c7fc422c9f848de09d58a7337.zip |
day24
Diffstat (limited to 'day24.bqn')
-rw-r--r-- | day24.bqn | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/day24.bqn b/day24.bqn new file mode 100644 index 0000000..b1df09a --- /dev/null +++ b/day24.bqn @@ -0,0 +1,22 @@ +# port of https://github.com/cettt/Advent_of_Code2021/blob/master/day_24.R +str←•Import"bqn-libs/strings.bqn" +Diff ← (¬∘∊/⊣) + +d←{•BQN⊑⌽" " str.Split 𝕩}¨ 4‿5‿15 ⊏⎉1 14‿∘⥊•FLines"day24" + +x1←eqidx←/9≥1⊏˘d +x2←⟨⟩ +x1minmax←⟨⟩ +x2minmax←⟨⟩ + +{ + x2 ∾↩ newmatch ← ⌈´ (↕𝕩) Diff x1∾x2 + b ← (newmatch‿2⊑d) + 𝕩‿1⊑d + minmax ← (0 (<⋈>) b) + (⌊´⋈⌈´) / (>⟜0 ∧ <⟜10) b+↕9 + x2minmax ∾↩ <minmax + x1minmax ∾↩ <minmax+b +}¨eqidx + +res←(x1∾˘>x1minmax)∾(x2∾˘>x2minmax) + +•Show '0'+⌽⍉1↓˘(⍋0⊏˘res)⊏res |