From cda29f36a8a42a7dad3b67cbad7f965113b0db1c Mon Sep 17 00:00:00 2001 From: Conor Hoekstra Date: Mon, 1 Sep 2025 16:57:24 -0400 Subject: :sparkles: Week 337 in BQN --- challenge-337/conor-hoekstra/ch-1.bqn | 13 +++++++++++++ challenge-337/conor-hoekstra/ch-2.bqn | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 challenge-337/conor-hoekstra/ch-1.bqn create mode 100644 challenge-337/conor-hoekstra/ch-2.bqn diff --git a/challenge-337/conor-hoekstra/ch-1.bqn b/challenge-337/conor-hoekstra/ch-1.bqn new file mode 100644 index 0000000000..3072130e2f --- /dev/null +++ b/challenge-337/conor-hoekstra/ch-1.bqn @@ -0,0 +1,13 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/337-1.bqn + +u ⇐ •Import "/home/cph/bqn-test/test.bqn" + +SmallerThanCurrent ← ¯1+·+´˘≥⌜˜ + +# Tests +u.UnitTest (SmallerThanCurrent ⟨6, 5, 4, 8⟩) ≡ ⟨2, 1, 0, 3⟩ +u.UnitTest (SmallerThanCurrent ⟨7, 7, 7, 7⟩) ≡ ⟨3, 3, 3, 3⟩ +u.UnitTest (SmallerThanCurrent ⟨5, 4, 3, 2, 1⟩) ≡ ⟨4, 3, 2, 1, 0⟩ +u.UnitTest (SmallerThanCurrent ⟨¯1, 0, 3, ¯2, 1⟩) ≡ ⟨1, 2, 4, 0, 3⟩ +u.UnitTest (SmallerThanCurrent ⟨0, 1, 1, 2, 0⟩) ≡ ⟨1, 3, 3, 4, 1⟩ diff --git a/challenge-337/conor-hoekstra/ch-2.bqn b/challenge-337/conor-hoekstra/ch-2.bqn new file mode 100644 index 0000000000..b0e2ef0014 --- /dev/null +++ b/challenge-337/conor-hoekstra/ch-2.bqn @@ -0,0 +1,16 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/337-2.bqn + +u ⇐ •Import "/home/cph/bqn-test/test.bqn" + +Row ← { 1⊸+⌾(𝕨⊸⊏)𝕩 } +Col ← ⍉Row⟜⍉ +RowCol ← { r‿c𝕊𝕩: r Row c Col 𝕩 } +OddMatrix ← { +´2|⥊(𝕨⥊0) RowCol´ 𝕩 } + +# Tests +u.UnitTest (2‿3 OddMatrix ⟨⟨0,1⟩,⟨1,1⟩⟩) ≡ 6 +u.UnitTest (2‿2 OddMatrix ⟨⟨1,1⟩,⟨0,0⟩⟩) ≡ 0 +u.UnitTest (3‿3 OddMatrix ⟨⟨0,0⟩,⟨1,2⟩,⟨2,1⟩⟩) ≡ 0 +u.UnitTest (1‿5 OddMatrix ⟨⟨0,2⟩,⟨0,4⟩⟩) ≡ 2 +u.UnitTest (4‿2 OddMatrix ⟨⟨1,0⟩,⟨3,1⟩,⟨2,0⟩,⟨0,1⟩⟩) ≡ 8 -- cgit