aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Hoekstra <codereport@outlook.com>2025-09-22 09:54:38 -0400
committerConor Hoekstra <codereport@outlook.com>2025-09-22 09:54:38 -0400
commit2c144195f02878836875ff351e57ecb92292c665 (patch)
tree3f383c261185f479a3e55a20201cb6f2054afa31
parent132d85acb6248fae868a795ba91fc752623f3bd8 (diff)
downloadperlweeklychallenge-club-2c144195f02878836875ff351e57ecb92292c665.tar.gz
perlweeklychallenge-club-2c144195f02878836875ff351e57ecb92292c665.tar.bz2
perlweeklychallenge-club-2c144195f02878836875ff351e57ecb92292c665.zip
:sparkles: Wek 340 in BQN
-rw-r--r--challenge-340/conor-hoekstra/ch-1.bqn14
-rw-r--r--challenge-340/conor-hoekstra/ch-2.bqn15
2 files changed, 29 insertions, 0 deletions
diff --git a/challenge-340/conor-hoekstra/ch-1.bqn b/challenge-340/conor-hoekstra/ch-1.bqn
new file mode 100644
index 0000000000..c43f038cd2
--- /dev/null
+++ b/challenge-340/conor-hoekstra/ch-1.bqn
@@ -0,0 +1,14 @@
+# For up to date code:
+# https://github.com/codereport/bqn-code/blob/main/pwc/340-1.bqn
+
+u ⇐ •Import "/home/cph/bqn-test/test.bqn"
+fn ⇐ •Import "/home/cph/bqn-code/lib/fun.bqn"
+
+RemoveDuplicates ← (∾·(1<≠)◶⟨⊢,2⊸↓⟩¨fn.Group)⍟≠
+
+# Tests
+u.UnitTest (RemoveDuplicates "abbaca") ≡ "ca"
+u.UnitTest (RemoveDuplicates "azxxzy") ≡ "ay"
+u.UnitTest (RemoveDuplicates "aaaaaaaa") ≡ ""
+u.UnitTest (RemoveDuplicates "aabccba") ≡ "a"
+u.UnitTest (RemoveDuplicates "abcddcba") ≡ ""
diff --git a/challenge-340/conor-hoekstra/ch-2.bqn b/challenge-340/conor-hoekstra/ch-2.bqn
new file mode 100644
index 0000000000..904f0729c4
--- /dev/null
+++ b/challenge-340/conor-hoekstra/ch-2.bqn
@@ -0,0 +1,15 @@
+# For up to date code:
+# https://github.com/codereport/bqn-code/blob/main/pwc/340-2.bqn
+
+u ⇐ •Import "/home/cph/bqn-test/test.bqn"
+s ⇐ •Import "/home/cph/bqn-code/lib/string.bqn"
+fn ⇐ •Import "/home/cph/bqn-code/lib/fun.bqn"
+
+AscendingNumbers ← ∧´0<·fn.Deltas s.Nats
+
+# Tests
+u.UnitTest (AscendingNumbers "The cat has 3 kittens 7 toys 10 beds") ≡ 1
+u.UnitTest (AscendingNumbers "Alice bought 5 apples 2 oranges 9 bananas") ≡ 0
+u.UnitTest (AscendingNumbers "I ran 1 mile 2 days 3 weeks 4 months") ≡ 1
+u.UnitTest (AscendingNumbers "Bob has 10 cars 10 bikes") ≡ 0
+u.UnitTest (AscendingNumbers "Zero is 0 one is 1 two is 2") ≡ 1