aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2024-07-26 10:12:01 +0100
committerGitHub <noreply@github.com>2024-07-26 10:12:01 +0100
commita4e38c86b5d4941071eb2ffe25bc3626625dfc61 (patch)
treef4792f46539e094817c52007b1c7064597b217e9
parent3be74d870975ade77f9ef5cf0030a13c33511131 (diff)
parent8fd0343b81b279fdd12009625081fe190be44ca9 (diff)
downloadperlweeklychallenge-club-a4e38c86b5d4941071eb2ffe25bc3626625dfc61.tar.gz
perlweeklychallenge-club-a4e38c86b5d4941071eb2ffe25bc3626625dfc61.tar.bz2
perlweeklychallenge-club-a4e38c86b5d4941071eb2ffe25bc3626625dfc61.zip
Merge pull request #10492 from wambash/challenge-week-279
solutions week 279
-rw-r--r--challenge-279/wambash/raku/ch-1.raku20
-rw-r--r--challenge-279/wambash/raku/ch-2.raku21
2 files changed, 41 insertions, 0 deletions
diff --git a/challenge-279/wambash/raku/ch-1.raku b/challenge-279/wambash/raku/ch-1.raku
new file mode 100644
index 0000000000..8e52054975
--- /dev/null
+++ b/challenge-279/wambash/raku/ch-1.raku
@@ -0,0 +1,20 @@
+#!/usr/bin/env raku
+
+sub sort-letters (@letters,@weights) {
+ @weights Z, @letters
+ andthen .map: { IntStr.new: |$_ }\
+ andthen .sort
+ andthen .join
+}
+
+multi MAIN (Bool :test($)!) {
+ use Test;
+ is sort-letters(<R E P L>, (3,2,1,4)),'PERL';
+ is sort-letters(<A U R K>, (2,4,1,3)),'RAKU';
+ is sort-letters(<O H Y N P T>, (5, 4, 2, 6, 1, 3)),'PYTHON';
+ done-testing;
+}
+
+multi MAIN ($letters,*@weights) {
+ say sort-letters $letters.comb, @weights
+}
diff --git a/challenge-279/wambash/raku/ch-2.raku b/challenge-279/wambash/raku/ch-2.raku
new file mode 100644
index 0000000000..5932519cbb
--- /dev/null
+++ b/challenge-279/wambash/raku/ch-2.raku
@@ -0,0 +1,21 @@
+#!/usr/bin/env raku
+
+sub split-string ($str) {
+ $str
+ andthen .comb: /:i <[aeiou]>/
+ andthen .elems
+ andthen $_ %% 2
+}
+
+multi MAIN (Bool :test($)!) {
+ use Test;
+ is split-string('perl'), False;
+ is split-string('book'), True;
+ is split-string('good morning'), True;
+ is split-string('Ook'), True;
+ done-testing;
+}
+
+multi MAIN ($str) {
+ say split-string $str
+}