aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-330/conor-hoekstra/ch-1.bqn14
-rw-r--r--challenge-330/conor-hoekstra/ch-2.bqn16
2 files changed, 30 insertions, 0 deletions
diff --git a/challenge-330/conor-hoekstra/ch-1.bqn b/challenge-330/conor-hoekstra/ch-1.bqn
new file mode 100644
index 0000000000..5ad557215e
--- /dev/null
+++ b/challenge-330/conor-hoekstra/ch-1.bqn
@@ -0,0 +1,14 @@
+# For up to date code:
+# https://github.com/codereport/bqn-code/blob/main/pwc/330-1.bqn
+
+u ⇐ •Import "/home/cph/bqn-test/test.bqn"
+s ⇐ •Import "/home/cph/bqn-code/lib/string.bqn"
+
+Bad ← { ∨´s.IsDigit¨𝕩 }
+Fix ← { 𝕩/˜¬(↕≠𝕩)∊¯1‿0+⊑/s.IsDigit¨𝕩 }
+ClearDigits ← { Fix•_while_ Bad 𝕩 }
+
+# Tests
+u.UnitTest (ClearDigits "cab12") ≡ "c"
+u.UnitTest (ClearDigits "xy99") ≡ ""
+u.UnitTest (ClearDigits "pa1erl") ≡ "perl"
diff --git a/challenge-330/conor-hoekstra/ch-2.bqn b/challenge-330/conor-hoekstra/ch-2.bqn
new file mode 100644
index 0000000000..6ce167b686
--- /dev/null
+++ b/challenge-330/conor-hoekstra/ch-2.bqn
@@ -0,0 +1,16 @@
+# For up to date code:
+# https://github.com/codereport/bqn-code/blob/main/pwc/330-2.bqn
+
+u ⇐ •Import "/home/cph/bqn-test/test.bqn"
+s ⇐ •Import "/home/cph/bqn-code/lib/string.bqn"
+
+TitleCapital ← { s.Unwords (2<≠)◶⊢‿(s.Upper⌾⊑)¨ s.Words s.Lower 𝕩 } # Explicit
+TitleCapital2 ← s.Unwords·(2<≠)◶⊢‿(s.Upper⌾⊑)¨·s.Words s.Lower # Tacit
+
+# Tests
+u.UnitTest (TitleCapital "PERL IS gREAT") ≡ "Perl is Great"
+u.UnitTest (TitleCapital "THE weekly challenge") ≡ "The Weekly Challenge"
+u.UnitTest (TitleCapital "YoU ARE A stAR") ≡ "You Are a Star"
+u.UnitTest (TitleCapital2 "PERL IS gREAT") ≡ "Perl is Great"
+u.UnitTest (TitleCapital2 "THE weekly challenge") ≡ "The Weekly Challenge"
+u.UnitTest (TitleCapital2 "YoU ARE A stAR") ≡ "You Are a Star"