aboutsummaryrefslogtreecommitdiff
path: root/challenge-331/barroff/raku
diff options
context:
space:
mode:
authorBarrOff <58253563+BarrOff@users.noreply.github.com>2025-07-27 21:30:46 +0200
committerBarrOff <58253563+BarrOff@users.noreply.github.com>2025-07-27 21:30:46 +0200
commit6e3e77bde9b6abffe7646340c6b4c00007227a9c (patch)
treee17e4f34d479873993d2dd3b6fed11e101f9f1be /challenge-331/barroff/raku
parent1ff2c9796a511d63231d3757acb27e4046a91fb2 (diff)
downloadperlweeklychallenge-club-6e3e77bde9b6abffe7646340c6b4c00007227a9c.tar.gz
perlweeklychallenge-club-6e3e77bde9b6abffe7646340c6b4c00007227a9c.tar.bz2
perlweeklychallenge-club-6e3e77bde9b6abffe7646340c6b4c00007227a9c.zip
feat: add solution for challenge 331 from BarrOff
Diffstat (limited to 'challenge-331/barroff/raku')
-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(' '));
+}