aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScimon <simon.proctor@gmail.com>2025-09-22 09:16:21 +0100
committerScimon <simon.proctor@gmail.com>2025-09-22 09:16:21 +0100
commit4d38c768d501560898fba785538832f605fe455b (patch)
treeb15ec832601a3f2af9c3ac8233b13991400ae49d
parentc4e70544812c339e0344ad3127de18a5dbf98c34 (diff)
downloadperlweeklychallenge-club-4d38c768d501560898fba785538832f605fe455b.tar.gz
perlweeklychallenge-club-4d38c768d501560898fba785538832f605fe455b.tar.bz2
perlweeklychallenge-club-4d38c768d501560898fba785538832f605fe455b.zip
Challenge 1
-rwxr-xr-xchallenge-340/simon-proctor/raku/ch-1.raku25
1 files changed, 25 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;
+}
+