aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-332/simon-proctor/raku/ch-1.raku21
-rwxr-xr-xchallenge-332/simon-proctor/raku/ch-2.raku18
2 files changed, 39 insertions, 0 deletions
diff --git a/challenge-332/simon-proctor/raku/ch-1.raku b/challenge-332/simon-proctor/raku/ch-1.raku
new file mode 100755
index 0000000000..153338265e
--- /dev/null
+++ b/challenge-332/simon-proctor/raku/ch-1.raku
@@ -0,0 +1,21 @@
+#!/usr/bin/env raku
+
+subset DateStr of Str where { my $r=False; try { Date.new($_); $r=True }; $r };
+
+multi sub MAIN(:t(:$test)) is hidden-from-USAGE {
+ use Test;
+ is binary-date("2025-07-26"), "11111101001-111-11010";
+ is binary-date("2000-02-02"), "11111010000-10-10";
+ is binary-date("2024-12-31"), "11111101000-1100-11111";
+}
+
+sub binary-date( DateStr $d ) {
+ $d.comb(/\d+/)>>.Int>>.base(2).join('-');
+}
+
+#| Given a date string output it in a binary format
+multi sub MAIN(
+ DateStr $d #= Valid Date String in yyyy-mm-dd format
+) {
+ say binary-date($d);
+}
diff --git a/challenge-332/simon-proctor/raku/ch-2.raku b/challenge-332/simon-proctor/raku/ch-2.raku
new file mode 100755
index 0000000000..ee9e564ca3
--- /dev/null
+++ b/challenge-332/simon-proctor/raku/ch-2.raku
@@ -0,0 +1,18 @@
+#!/usr/bin/env raku
+
+multi sub MAIN(:t(:$test)) is hidden-from-USAGE {
+ use Test;
+ ok !odd-letters("weekly");
+ ok odd-letters("perl");
+ ok !odd-letters("challenge");
+ done-testing;
+}
+
+sub odd-letters (Str $check) {
+ ! any($check.comb.Bag.values >>%%>> 2)
+}
+
+#|( Given a string print whether each character in
+it appears an odd number of times)
+multi sub MAIN(Str $s) {say odd-letters($s)}
+