diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-10-26 23:28:45 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-26 23:28:45 +0000 |
| commit | 56f4f1147e94916513150b6ee4147a447415c5cd (patch) | |
| tree | c6da6debfe1712da90e741ee7a9e942eec732459 | |
| parent | d5cfdd8f6575535178ddd3c8a74699b17bbbad00 (diff) | |
| parent | 03be81377fc1ec1962e44e713f2cc9081da9c2f9 (diff) | |
| download | perlweeklychallenge-club-56f4f1147e94916513150b6ee4147a447415c5cd.tar.gz perlweeklychallenge-club-56f4f1147e94916513150b6ee4147a447415c5cd.tar.bz2 perlweeklychallenge-club-56f4f1147e94916513150b6ee4147a447415c5cd.zip | |
Merge pull request #12923 from BarrOff/barroff-344
feat: add solution for challenge 344 from BarrOff
| -rw-r--r-- | challenge-344/barroff/raku/ch-2.p6 | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-344/barroff/raku/ch-2.p6 b/challenge-344/barroff/raku/ch-2.p6 new file mode 100644 index 0000000000..9caaa0c14b --- /dev/null +++ b/challenge-344/barroff/raku/ch-2.p6 @@ -0,0 +1,23 @@ +#!/usr/bin/env raku + +use v6.d; + +sub array-formation(@source, @target --> Bool) { + my Str $targetString = @target.Str; + return so map({ $_.Str }, @source.permutations).any eq $targetString; +} + +#| Run test cases +sub MAIN('test') { + use Test; + plan 5; + + is array-formation(([2,3], [1], [4]), (1, 2, 3, 4)), True, + 'works for "(2,3], [1], [4])"'; + is array-formation(([1,3], [2,4]), (1, 2, 3, 4)), False, + 'works for "([1,3], [2,4])"'; + is array-formation(([9,1], [5,8], [2]), (5, 8, 2, 9, 1)), True, + 'works for "([9,1], [5,8], [2])"'; + is array-formation(([1], [3]), (1, 2, 3)), False, 'works for "([1], [3])"'; + is array-formation(([7,4,6]), (7, 4, 6)), True, 'works for "([7,4,6])"'; +} |
