aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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⟩