From 75a270957f19df561b803588f7f465dc31106e33 Mon Sep 17 00:00:00 2001 From: Conor Hoekstra Date: Mon, 27 Jan 2025 11:07:32 -0500 Subject: :sparkles: Week 306 in BQN --- challenge-306/conor-hoekstra/ch-1.bqn | 13 +++++++++++++ challenge-306/conor-hoekstra/ch-2.bqn | 10 ++++++++++ 2 files changed, 23 insertions(+) create mode 100644 challenge-306/conor-hoekstra/ch-1.bqn create mode 100644 challenge-306/conor-hoekstra/ch-2.bqn 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 -- cgit