aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Hoekstra <codereport@outlook.com>2025-08-04 13:58:53 -0400
committerConor Hoekstra <codereport@outlook.com>2025-08-04 13:58:53 -0400
commit7ed6f63830c9d9e7c26614faf8bfc2814ad82cbf (patch)
tree631b9679de4e6870e89e5410fdef234ed03f15e1
parentce2f933a023e15e5dac73508e56a9aec0e87fae6 (diff)
downloadperlweeklychallenge-club-7ed6f63830c9d9e7c26614faf8bfc2814ad82cbf.tar.gz
perlweeklychallenge-club-7ed6f63830c9d9e7c26614faf8bfc2814ad82cbf.tar.bz2
perlweeklychallenge-club-7ed6f63830c9d9e7c26614faf8bfc2814ad82cbf.zip
:sparkles: Week 333 in BQN
-rw-r--r--challenge-333/conor-hoekstra/ch-1.bqn13
-rw-r--r--challenge-333/conor-hoekstra/ch-2.bqn19
2 files changed, 32 insertions, 0 deletions
diff --git a/challenge-333/conor-hoekstra/ch-1.bqn b/challenge-333/conor-hoekstra/ch-1.bqn
new file mode 100644
index 0000000000..95dfaa217b
--- /dev/null
+++ b/challenge-333/conor-hoekstra/ch-1.bqn
@@ -0,0 +1,13 @@
+# For up to date code:
+# https://github.com/codereport/bqn-code/blob/main/pwc/333-1.bqn
+
+u ⇐ •Import "/home/cph/bqn-test/test.bqn"
+
+StraightLine ← { ∧´≡´¨(⌽-´2↑𝕩)⊸ר(⊑𝕩)⊸-¨(1↓𝕩) }
+
+# Tests
+u.UnitTest (StraightLine ⟨⟨2, 1⟩, ⟨2, 3⟩, ⟨2, 5⟩⟩) ≡ 1
+u.UnitTest (StraightLine ⟨⟨1, 4⟩, ⟨3, 4⟩, ⟨10, 4⟩⟩) ≡ 1
+u.UnitTest (StraightLine ⟨⟨0, 0⟩, ⟨1, 1⟩, ⟨2, 3⟩⟩) ≡ 0
+u.UnitTest (StraightLine ⟨⟨1, 1⟩, ⟨1, 1⟩, ⟨1, 1⟩⟩) ≡ 1
+u.UnitTest (StraightLine ⟨⟨1000000, 1000000⟩, ⟨2000000, 2000000⟩, ⟨3000000, 3000000⟩⟩) ≡ 1
diff --git a/challenge-333/conor-hoekstra/ch-2.bqn b/challenge-333/conor-hoekstra/ch-2.bqn
new file mode 100644
index 0000000000..9e1c5a24bf
--- /dev/null
+++ b/challenge-333/conor-hoekstra/ch-2.bqn
@@ -0,0 +1,19 @@
+# For up to date code:
+# https://github.com/codereport/bqn-code/blob/main/pwc/333-2.bqn
+
+u ⇐ •Import "/home/cph/bqn-test/test.bqn"
+
+DuplicateZeros ← { (≠𝕩)↑𝕩/˜1+0=𝕩 } # Explicit
+DuplicateZeros2 ← ≠↑(1+0=⊢)⊸/ # Tacit
+
+# Tests
+u.UnitTest (DuplicateZeros ⟨1, 0, 2, 3, 0, 4, 5, 0⟩) ≡ ⟨1, 0, 0, 2, 3, 0, 0, 4⟩
+u.UnitTest (DuplicateZeros ⟨1, 2, 3⟩) ≡ ⟨1, 2, 3⟩
+u.UnitTest (DuplicateZeros ⟨1, 2, 3, 0⟩) ≡ ⟨1, 2, 3, 0⟩
+u.UnitTest (DuplicateZeros ⟨0, 0, 1, 2⟩) ≡ ⟨0, 0, 0, 0⟩
+u.UnitTest (DuplicateZeros ⟨1, 2, 0, 3, 4⟩) ≡ ⟨1, 2, 0, 0, 3⟩
+u.UnitTest (DuplicateZeros2 ⟨1, 0, 2, 3, 0, 4, 5, 0⟩) ≡ ⟨1, 0, 0, 2, 3, 0, 0, 4⟩
+u.UnitTest (DuplicateZeros2 ⟨1, 2, 3⟩) ≡ ⟨1, 2, 3⟩
+u.UnitTest (DuplicateZeros2 ⟨1, 2, 3, 0⟩) ≡ ⟨1, 2, 3, 0⟩
+u.UnitTest (DuplicateZeros2 ⟨0, 0, 1, 2⟩) ≡ ⟨0, 0, 0, 0⟩
+u.UnitTest (DuplicateZeros2 ⟨1, 2, 0, 3, 4⟩) ≡ ⟨1, 2, 0, 0, 3⟩