aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarrOff <58253563+BarrOff@users.noreply.github.com>2025-04-20 23:52:03 +0200
committerBarrOff <58253563+BarrOff@users.noreply.github.com>2025-04-20 23:52:34 +0200
commit82e0d8ec4d23bc151a7393cd0a8c9fd78897f875 (patch)
tree83bc7253a807830a5e618b24b9d357b123b50a86
parent5ca23d4fc77e7d23d84a683afd344d98c2aa1093 (diff)
downloadperlweeklychallenge-club-82e0d8ec4d23bc151a7393cd0a8c9fd78897f875.tar.gz
perlweeklychallenge-club-82e0d8ec4d23bc151a7393cd0a8c9fd78897f875.tar.bz2
perlweeklychallenge-club-82e0d8ec4d23bc151a7393cd0a8c9fd78897f875.zip
feat: add solution for challenge 317 from BarrOff
-rw-r--r--challenge-317/barroff/raku/ch-1.p622
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-317/barroff/raku/ch-1.p6 b/challenge-317/barroff/raku/ch-1.p6
new file mode 100644
index 0000000000..a2446b28c2
--- /dev/null
+++ b/challenge-317/barroff/raku/ch-1.p6
@@ -0,0 +1,22 @@
+#!/usr/bin/env raku
+
+use v6.d;
+
+sub acronyms(@array, Str $word --> Bool) {
+ $word eq map({ ($_.comb)[0] }, @array).join;
+}
+
+#| Run test cases
+multi sub MAIN('test') {
+ use Test;
+ plan 3;
+
+ is acronyms(["Perl", "Weekly", "Challenge"], "PWC"), True, 'works for "PWC"';
+ is acronyms(["Bob", "Charlie", "Joe"], "BCJ"), True, 'works for "BCJ"';
+ is acronyms(["Morning", "Good"], "MM"), False, 'works for "MM"';
+}
+
+#| Take user provided number like PWC Perl Weekly Challenge"
+multi sub MAIN(Str $word, *@array) {
+ say acronyms(@array, $word);
+}