From 82e0d8ec4d23bc151a7393cd0a8c9fd78897f875 Mon Sep 17 00:00:00 2001 From: BarrOff <58253563+BarrOff@users.noreply.github.com> Date: Sun, 20 Apr 2025 23:52:03 +0200 Subject: feat: add solution for challenge 317 from BarrOff --- challenge-317/barroff/raku/ch-1.p6 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 challenge-317/barroff/raku/ch-1.p6 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); +} -- cgit