diff options
author | sterni <sternenseemann@systemli.org> | 2024-12-20T13·22+0100 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-12-20T17·39+0000 |
commit | de4004a8ead792919282f5f4bba78ef0c01058e8 (patch) | |
tree | a00447943d8ce327b318671dbb5a81fdbf161774 | |
parent | 88e65b5c333d10260782df6be887d03b8a0f7731 (diff) |
feat(sterni/exercises/lib): add Diagonals BQN function r/9010
Retrieves all diagonals of a two dimensional array (which have differing lengths). Useful to solve e.g. Project Euler problem 11 (<https://projecteuler.net/problem=11>). Change-Id: I853bc6eaaf869326d84d8e789fee9995f5a332d8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12897 Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
-rw-r--r-- | users/sterni/exercises/aoc/lib.bqn | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/users/sterni/exercises/aoc/lib.bqn b/users/sterni/exercises/aoc/lib.bqn index e870a5dfa426..5c02358b5980 100644 --- a/users/sterni/exercises/aoc/lib.bqn +++ b/users/sterni/exercises/aoc/lib.bqn @@ -16,3 +16,6 @@ _fix ⇐ {𝕩 𝕊∘⊢⍟≢ 𝔽 𝕩} ImportBqnLibs ⇐ {•Import 𝕩∾˜"/"∾˜¯1↓1⊑•SH "printenv"‿"BQNLIBS"} Xor ⇐ (¬⊸∧∨∧⟜¬) + +# To get all Diagonals (⊢∾○Diagonals⌽) +Diagonals ⇐ {(0‿0⊸⍉ ↓⟜𝕩)¨ (↕≠𝕩)} |