aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-306/conor-hoekstra/ch-1.bqn13
-rw-r--r--challenge-306/conor-hoekstra/ch-2.bqn10
2 files changed, 23 insertions, 0 deletions
diff --git a/challenge-306/conor-hoekstra/ch-1.bqn b/challenge-306/conor-hoekstra/ch-1.bqn
new file mode 100644
index 0000000000..f6bfefe208
--- /dev/null
+++ b/challenge-306/conor-hoekstra/ch-1.bqn
@@ -0,0 +1,13 @@
+# For up to date code:
+# https://github.com/codereport/bqn-code/blob/main/pwc/306-1.bqn
+
+u ⇐ •Import "/home/cph/bqn-test/test.bqn"
+
+OddSum ← { +´∾⥊¨(1+2×↕⌈2÷˜≠𝕩)↕¨<𝕩 } # Explicit
+OddSum2 ← +´·∾·⥊¨((1+2×↕)·⌈2÷˜≠)↕¨< # Tacit
+
+# Tests
+u.UnitTest (OddSum ⟨2,5,3,6,4⟩) ≡ 77
+u.UnitTest (OddSum ⟨1,3⟩) ≡ 4
+u.UnitTest (OddSum2 ⟨2,5,3,6,4⟩) ≡ 77
+u.UnitTest (OddSum2 ⟨1,3⟩) ≡ 4
diff --git a/challenge-306/conor-hoekstra/ch-2.bqn b/challenge-306/conor-hoekstra/ch-2.bqn
new file mode 100644
index 0000000000..fc335e0e6e
--- /dev/null
+++ b/challenge-306/conor-hoekstra/ch-2.bqn
@@ -0,0 +1,10 @@
+# For up to date code:
+# https://github.com/codereport/bqn-code/blob/main/pwc/306-2.bqn
+
+u ⇐ •Import "/home/cph/bqn-test/test.bqn"
+
+LastElement ← { 1≥≠𝕩 ? ⊑𝕩∾0 ; 𝕊(2↓s)∾≠´◶⟨⟩‿(⋈∘-´)2↑s ← ∨𝕩 }
+
+# Tests
+u.UnitTest (LastElement ⟨3, 8, 5, 2, 9, 2⟩) ≡ 1
+u.UnitTest (LastElement ⟨3, 2, 5⟩) ≡ 0