diff options
| author | Andrew Shitov <mail@andreyshitov.com> | 2025-09-29 11:22:09 +0200 |
|---|---|---|
| committer | Andrew Shitov <mail@andreyshitov.com> | 2025-09-29 11:22:09 +0200 |
| commit | e6cbdd695bdeb858d0cf47a75197febce20ae5ee (patch) | |
| tree | a61c4e8dfb9ad147325ef805086814c8020e2bff | |
| parent | dd9dab4686fc230480c1ba07dc81492311c1d41f (diff) | |
| download | perlweeklychallenge-club-e6cbdd695bdeb858d0cf47a75197febce20ae5ee.tar.gz perlweeklychallenge-club-e6cbdd695bdeb858d0cf47a75197febce20ae5ee.tar.bz2 perlweeklychallenge-club-e6cbdd695bdeb858d0cf47a75197febce20ae5ee.zip | |
Raku solutions Week 341 by @ash
| -rw-r--r-- | challenge-341/ash/raku/ch-1.raku | 18 | ||||
| -rw-r--r-- | challenge-341/ash/raku/ch-2.raku | 14 |
2 files changed, 32 insertions, 0 deletions
diff --git a/challenge-341/ash/raku/ch-1.raku b/challenge-341/ash/raku/ch-1.raku new file mode 100644 index 0000000000..ccd63a5848 --- /dev/null +++ b/challenge-341/ash/raku/ch-1.raku @@ -0,0 +1,18 @@ +# Task 1 of the Weekly Challenge 341 +# https://theweeklychallenge.org/blog/perl-weekly-challenge-341/#TASK1 + +say count-words('Hello World', ['d']); # 1 +say count-words('apple banana cherry', ['a', 'e']); # 0 +say count-words('Coding is fun', []); # 3 +say count-words('The Weekly Challenge', ['a','b']); # 2 +say count-words('Perl and Python', ['p']); # 1 + +sub count-words($string, @broken-keys) { + my @words = $string.lc.words; + my $possible-words = @words.elems; + for @words -> $word { + $possible-words-- if $word.comb (&) @broken-keys; + } + + return $possible-words; +} diff --git a/challenge-341/ash/raku/ch-2.raku b/challenge-341/ash/raku/ch-2.raku new file mode 100644 index 0000000000..1375a3ec4d --- /dev/null +++ b/challenge-341/ash/raku/ch-2.raku @@ -0,0 +1,14 @@ +# Task 2 of the Weekly Challenge 341 +# https://theweeklychallenge.org/blog/perl-weekly-challenge-341/#TASK2 + +say reverse-prefix('programming', 'g'); # gorpramming +say reverse-prefix('hello', 'h'); # hello +say reverse-prefix('abcdefghij', 'h'); # hgfedcbaij +say reverse-prefix('reverse', 's'); # srevere +say reverse-prefix('perl', 'r'); # repl + +sub reverse-prefix($word, $char) { + $word ~~ /^ (.*? $char) (.*) $/; + + return $/[0].flip ~ $/[1]; +} |
