aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-09-22 23:49:03 +0100
committerGitHub <noreply@github.com>2025-09-22 23:49:03 +0100
commit3ab2e3e89bd6dce8fed7cd9d07c03c936e0f810b (patch)
tree90e3c67ba42910ad2864307ef0a3011261873bc2
parent0cce296f2d0d3bf20f1153035d45417977ac933e (diff)
parent82b5606c3f5db95c24321831f597e9be621229a0 (diff)
downloadperlweeklychallenge-club-3ab2e3e89bd6dce8fed7cd9d07c03c936e0f810b.tar.gz
perlweeklychallenge-club-3ab2e3e89bd6dce8fed7cd9d07c03c936e0f810b.tar.bz2
perlweeklychallenge-club-3ab2e3e89bd6dce8fed7cd9d07c03c936e0f810b.zip
Merge pull request #12717 from Scimon/master
Challenges done
-rwxr-xr-xchallenge-340/simon-proctor/raku/ch-1.raku25
-rwxr-xr-xchallenge-340/simon-proctor/raku/ch-2.raku20
2 files changed, 45 insertions, 0 deletions
diff --git a/challenge-340/simon-proctor/raku/ch-1.raku b/challenge-340/simon-proctor/raku/ch-1.raku
new file mode 100755
index 0000000000..af190284e9
--- /dev/null
+++ b/challenge-340/simon-proctor/raku/ch-1.raku
@@ -0,0 +1,25 @@
+#!/usr/bin/env raku
+
+subset IsTrue of Bool where so *;
+
+multi sub MAIN( IsTrue :t(:$test) ) is hidden-from-USAGE {
+ use Test;
+ is strip-dupes('abbaca'), 'ca';
+ is strip-dupes('azxxzy'), 'ay';
+ is strip-dupes('aaaaaaaa'), '';
+ is strip-dupes('aabccba'), 'a';
+ is strip-dupes('abcddcba'), '';
+ done-testing;
+}
+
+multi sub MAIN( Str() $s ) { strip-dupes($s).say; }
+
+sub strip-dupes( Str $s is copy ) {
+ my $old = $s;
+ repeat {
+ $old = $s;
+ $s ~~ s:g/(.)$0//;
+ } until ( $old ~~ $s );
+ $s;
+}
+
diff --git a/challenge-340/simon-proctor/raku/ch-2.raku b/challenge-340/simon-proctor/raku/ch-2.raku
new file mode 100755
index 0000000000..84dbca259a
--- /dev/null
+++ b/challenge-340/simon-proctor/raku/ch-2.raku
@@ -0,0 +1,20 @@
+#!/usr/bin/env raku
+
+subset IsTrue of Bool where so *;
+
+multi sub MAIN( IsTrue :t(:$test) ) is hidden-from-USAGE {
+ use Test;
+ ok ascending("The cat has 3 kittens 7 toys 10 beds");
+ nok ascending('Alice bought 5 apples 2 oranges 9 bananas');
+ ok ascending('I ran 1 mile 2 days 3 weeks 4 months');
+ nok ascending('Bob has 10 cars 10 bikes');
+ ok ascending('Zero is 0 one is 1 two is 2');
+ done-testing;
+}
+
+multi sub MAIN( Str $s ) { ascending($s).say; }
+multi sub MAIN( *@s ) { ascending( @s.join(" ") ).say; }
+
+sub ascending( Str $s ) {
+ [<] $s.comb(/\d+/);
+}