From 4d38c768d501560898fba785538832f605fe455b Mon Sep 17 00:00:00 2001 From: Scimon Date: Mon, 22 Sep 2025 09:16:21 +0100 Subject: Challenge 1 --- challenge-340/simon-proctor/raku/ch-1.raku | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 challenge-340/simon-proctor/raku/ch-1.raku 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; +} + -- cgit From 82b5606c3f5db95c24321831f597e9be621229a0 Mon Sep 17 00:00:00 2001 From: Scimon Date: Mon, 22 Sep 2025 09:25:40 +0100 Subject: Challenge 2 --- challenge-340/simon-proctor/raku/ch-2.raku | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 challenge-340/simon-proctor/raku/ch-2.raku 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+/); +} -- cgit