aboutsummaryrefslogtreecommitdiff
path: root/challenge-331
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-07-31 10:27:22 +0100
committerGitHub <noreply@github.com>2025-07-31 10:27:22 +0100
commitfd7295adcd11759e120d5e8ccec537c08d6bbe73 (patch)
treeb281aa13f8df5ed7d58f30fbdddacf2814af6f2b /challenge-331
parent5253bc548ec406be0665ab09bbc6431406a8f873 (diff)
parent6e3e77bde9b6abffe7646340c6b4c00007227a9c (diff)
downloadperlweeklychallenge-club-fd7295adcd11759e120d5e8ccec537c08d6bbe73.tar.gz
perlweeklychallenge-club-fd7295adcd11759e120d5e8ccec537c08d6bbe73.tar.bz2
perlweeklychallenge-club-fd7295adcd11759e120d5e8ccec537c08d6bbe73.zip
Merge pull request #12428 from BarrOff/barroff-331
feat: add solution for challenge 331 from BarrOff
Diffstat (limited to 'challenge-331')
-rw-r--r--challenge-331/barroff/raku/ch-1.p622
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-331/barroff/raku/ch-1.p6 b/challenge-331/barroff/raku/ch-1.p6
new file mode 100644
index 0000000000..2668667bdc
--- /dev/null
+++ b/challenge-331/barroff/raku/ch-1.p6
@@ -0,0 +1,22 @@
+#!/usr/bin/env raku
+
+use v6.d;
+
+sub last-word(Str $str --> Int) {
+ ($str.words)[* - 1].chars;
+}
+
+#| Run test cases
+multi sub MAIN('test') {
+ use Test;
+ plan 3;
+
+ is last-word("The Weekly Challenge"), 9, 'works for "The Weekly Challenge"';
+ is last-word(" Hello World "), 5, 'works for " Hello World "';
+ is last-word("Let's begin the fun"), 3, 'works for "Let\'s begin the fun"';
+}
+
+#| Take user provided number like "Perl Weekly Challenge" l a
+multi sub MAIN(*@words) {
+ say last-word(@words.join(' '));
+}