diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2024-09-21 09:13:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-21 09:13:05 +0100 |
| commit | 3a27ce87ecfb71816386a383ebc5c342d20283ef (patch) | |
| tree | 3d5d99a00ea7e4944d2a1342fb02a4261175cea1 | |
| parent | 5a12d6e9d1c27496b9e64bfdebbd727cdcf62f93 (diff) | |
| parent | aca0e6cc3613ecf67bd709490986bf1fce6b0645 (diff) | |
| download | perlweeklychallenge-club-3a27ce87ecfb71816386a383ebc5c342d20283ef.tar.gz perlweeklychallenge-club-3a27ce87ecfb71816386a383ebc5c342d20283ef.tar.bz2 perlweeklychallenge-club-3a27ce87ecfb71816386a383ebc5c342d20283ef.zip | |
Merge pull request #10883 from codereport/master
✨ Week 78 & 82 in BQN (& 1 APL)
| -rw-r--r-- | challenge-078/conor-hoekstra/ch-1.bqn | 8 | ||||
| -rw-r--r-- | challenge-078/conor-hoekstra/ch-2.apl | 14 | ||||
| -rw-r--r-- | challenge-078/conor-hoekstra/ch-2.bqn | 17 | ||||
| -rw-r--r-- | challenge-082/conor-hoekstra/ch-1.bqn | 9 | ||||
| -rw-r--r-- | challenge-082/conor-hoekstra/ch-2.bqn | 10 |
5 files changed, 58 insertions, 0 deletions
diff --git a/challenge-078/conor-hoekstra/ch-1.bqn b/challenge-078/conor-hoekstra/ch-1.bqn new file mode 100644 index 0000000000..54f55bf3f4 --- /dev/null +++ b/challenge-078/conor-hoekstra/ch-1.bqn @@ -0,0 +1,8 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/078-1.bqn + +LeaderElement ← ⍷⌈`⌾⌽ + +# Tests +•Show LeaderElement ⟨9, 10, 7, 5, 6, 1⟩ # ⟨10, 7, 6, 1⟩ +•Show LeaderElement ⟨3, 4, 5⟩ # ⟨5⟩ diff --git a/challenge-078/conor-hoekstra/ch-2.apl b/challenge-078/conor-hoekstra/ch-2.apl new file mode 100644 index 0000000000..5a696c2bef --- /dev/null +++ b/challenge-078/conor-hoekstra/ch-2.apl @@ -0,0 +1,14 @@ +LeftRotate ← ↑⌽¨∘⊂ + +⍝ Tests + +3 4 LeftRotate 10 20 30 40 50 +⍝ Output: +⍝ [40 50 10 20 30] +⍝ [50 10 20 30 40] + +1 3 4 LeftRotate 7 4 2 6 3 +⍝ Output: +⍝ [4 2 6 3 7] +⍝ [6 3 7 4 2] +⍝ [3 7 4 2 6] diff --git a/challenge-078/conor-hoekstra/ch-2.bqn b/challenge-078/conor-hoekstra/ch-2.bqn new file mode 100644 index 0000000000..7848e90a68 --- /dev/null +++ b/challenge-078/conor-hoekstra/ch-2.bqn @@ -0,0 +1,17 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/078-2.bqn + +LeftRotate ← >⌽¨⟜< + +# Tests + +•Show ⟨3,4⟩ LeftRotate ⟨10,20,30,40,50⟩ +# Output: +# [40 50 10 20 30] +# [50 10 20 30 40] + +•Show ⟨1,3,4⟩ LeftRotate ⟨7,4,2,6,3⟩ +# Output: +# [4 2 6 3 7] +# [6 3 7 4 2] +# [3 7 4 2 6] diff --git a/challenge-082/conor-hoekstra/ch-1.bqn b/challenge-082/conor-hoekstra/ch-1.bqn new file mode 100644 index 0000000000..7fc31d78da --- /dev/null +++ b/challenge-082/conor-hoekstra/ch-1.bqn @@ -0,0 +1,9 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/082-1.bqn + +Factors ← (1+↕)(⊣/˜0=|)⊢ +CommonFactors ← (∊/⊣)○Factors + +# Tests +•Show 12 CommonFactors 18 # ⟨ 1 2 3 6 ⟩ +•Show 18 CommonFactors 23 # ⟨ 1 ⟩ diff --git a/challenge-082/conor-hoekstra/ch-2.bqn b/challenge-082/conor-hoekstra/ch-2.bqn new file mode 100644 index 0000000000..4056ed6a57 --- /dev/null +++ b/challenge-082/conor-hoekstra/ch-2.bqn @@ -0,0 +1,10 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/082-2.bqn + +Interleave ← { n𝕊a‿b: n(↑(∾⟜b⊸∾)↓)a } +IsInterleaved ← { ∨´𝕨⊸≡¨(↕≠⊑𝕩)Interleave¨<𝕩 } + +# Tests +•Show "XXY" IsInterleaved "XY"‿"X" # 1 +•Show "XXXXZY" IsInterleaved "XXY"‿"XXZ" # 1 +•Show "XXY" IsInterleaved "YX"‿"X" # 0 |
