diff options
| -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 |
