From f5e94e61241e2fdf881635f0aee9a49db72e9d26 Mon Sep 17 00:00:00 2001 From: Conor Hoekstra Date: Fri, 20 Sep 2024 23:35:22 -0400 Subject: :sparkles: Week 78 & 82 in BQN --- challenge-078/conor-hoekstra/ch-1.bqn | 8 ++++++++ challenge-078/conor-hoekstra/ch-2.bqn | 17 +++++++++++++++++ challenge-082/conor-hoekstra/ch-1.bqn | 9 +++++++++ challenge-082/conor-hoekstra/ch-2.bqn | 10 ++++++++++ 4 files changed, 44 insertions(+) create mode 100644 challenge-078/conor-hoekstra/ch-1.bqn create mode 100644 challenge-078/conor-hoekstra/ch-2.bqn create mode 100644 challenge-082/conor-hoekstra/ch-1.bqn create mode 100644 challenge-082/conor-hoekstra/ch-2.bqn 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.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..3f605e9c0a --- /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 +•Show 18 CommonFactors 23 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 -- cgit