aboutsummaryrefslogtreecommitdiff
path: root/challenge-321
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-05-13 13:22:44 +0100
committerGitHub <noreply@github.com>2025-05-13 13:22:44 +0100
commit27bd6ee96e9a37c1ffa7bc269060062795bbaae4 (patch)
treedc4c3461d6e2b7ec4836be480dbba1bf2c06802d /challenge-321
parent2172bd6099b34a2ec8e4104e77ba9d825225a356 (diff)
parent56c7597a1cd4c82a5902be0ebbd377b588c770c3 (diff)
downloadperlweeklychallenge-club-27bd6ee96e9a37c1ffa7bc269060062795bbaae4.tar.gz
perlweeklychallenge-club-27bd6ee96e9a37c1ffa7bc269060062795bbaae4.tar.bz2
perlweeklychallenge-club-27bd6ee96e9a37c1ffa7bc269060062795bbaae4.zip
Merge pull request #12020 from codereport/master
:sparkles: Week 321 in BQN
Diffstat (limited to 'challenge-321')
-rw-r--r--challenge-321/conor-hoekstra/ch-1.bqn15
-rw-r--r--challenge-321/conor-hoekstra/ch-2.bqn12
2 files changed, 27 insertions, 0 deletions
diff --git a/challenge-321/conor-hoekstra/ch-1.bqn b/challenge-321/conor-hoekstra/ch-1.bqn
new file mode 100644
index 0000000000..a67f8afb62
--- /dev/null
+++ b/challenge-321/conor-hoekstra/ch-1.bqn
@@ -0,0 +1,15 @@
+# For up to date code:
+# https://github.com/codereport/bqn-code/blob/main/pwc/321-1.bqn
+
+u ⇐ •Import "/home/cph/bqn-test/test.bqn"
+
+DistinctAverage ← { ≠⍷+˝⌽⌾⊏2‿∘⥊∧𝕩 } # Explicit
+DistinctAverage2 ← ≠·⍷·+˝·⌽⌾⊏2‿∘⥊∧ # Tacit
+
+# Tests
+u.UnitTest (DistinctAverage ⟨1, 2, 4, 3, 5, 6⟩) ≡ 1
+u.UnitTest (DistinctAverage ⟨0, 2, 4, 8, 3, 5⟩) ≡ 2
+u.UnitTest (DistinctAverage ⟨7, 3, 1, 0, 5, 9⟩) ≡ 2
+u.UnitTest (DistinctAverage2 ⟨1, 2, 4, 3, 5, 6⟩) ≡ 1
+u.UnitTest (DistinctAverage2 ⟨0, 2, 4, 8, 3, 5⟩) ≡ 2
+u.UnitTest (DistinctAverage2 ⟨7, 3, 1, 0, 5, 9⟩) ≡ 2
diff --git a/challenge-321/conor-hoekstra/ch-2.bqn b/challenge-321/conor-hoekstra/ch-2.bqn
new file mode 100644
index 0000000000..8a98af3d4a
--- /dev/null
+++ b/challenge-321/conor-hoekstra/ch-2.bqn
@@ -0,0 +1,12 @@
+# For up to date code:
+# https://github.com/codereport/bqn-code/blob/main/pwc/321-2.bqn
+
+u ⇐ •Import "/home/cph/bqn-test/test.bqn"
+
+Norm ← 0>·(⊢⌈+)`⌾⌽·-⟜¬'#'=⊢
+BackspaceCompare ← ≡○Norm
+
+# Tests
+u.UnitTest ("ad#c" BackspaceCompare "ab#c") ≡ 1
+u.UnitTest ("ab##" BackspaceCompare "a#b#") ≡ 1
+u.UnitTest ( "a#b" BackspaceCompare "c" ) ≡ 0