aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
+}