diff options
| author | Conor Hoekstra <codereport@outlook.com> | 2025-05-12 13:08:03 -0400 |
|---|---|---|
| committer | Conor Hoekstra <codereport@outlook.com> | 2025-05-12 13:08:03 -0400 |
| commit | 56c7597a1cd4c82a5902be0ebbd377b588c770c3 (patch) | |
| tree | 82350979325da18ea92fa010e36031179bdaac91 | |
| parent | 62f1ccaddfc5a65501df9cfdf528d28927fef410 (diff) | |
| download | perlweeklychallenge-club-56c7597a1cd4c82a5902be0ebbd377b588c770c3.tar.gz perlweeklychallenge-club-56c7597a1cd4c82a5902be0ebbd377b588c770c3.tar.bz2 perlweeklychallenge-club-56c7597a1cd4c82a5902be0ebbd377b588c770c3.zip | |
:sparkles: Week 321 in BQN
| -rw-r--r-- | challenge-321/conor-hoekstra/ch-1.bqn | 15 | ||||
| -rw-r--r-- | challenge-321/conor-hoekstra/ch-2.bqn | 12 |
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 |
