diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-10-20 17:05:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-20 17:05:11 +0100 |
| commit | d122adfef69ff5312bb4d20cb631cccf4592ae64 (patch) | |
| tree | f54ba9b38ebf4795851cc2b85157050086c0c5f3 | |
| parent | 79fbae1caeecaa7ecf19384997d7955baa548591 (diff) | |
| parent | b593d089470c8512690aa68b5510ec3c22f35263 (diff) | |
| download | perlweeklychallenge-club-d122adfef69ff5312bb4d20cb631cccf4592ae64.tar.gz perlweeklychallenge-club-d122adfef69ff5312bb4d20cb631cccf4592ae64.tar.bz2 perlweeklychallenge-club-d122adfef69ff5312bb4d20cb631cccf4592ae64.zip | |
Merge pull request #12885 from andemark/challenge-344
ch-2.raku do-over
| -rw-r--r-- | challenge-344/mark-anderson/raku/ch-2.raku | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/challenge-344/mark-anderson/raku/ch-2.raku b/challenge-344/mark-anderson/raku/ch-2.raku new file mode 100644 index 0000000000..f637abeb61 --- /dev/null +++ b/challenge-344/mark-anderson/raku/ch-2.raku @@ -0,0 +1,31 @@ +#!/usr/bin/env raku +use Test; + +ok array-formation([[2,3],[1],[4]], [1,2,3,4]); +nok array-formation([[1,3],[2,4]], [1,2,3,4]); +ok array-formation([[9,1],[5,8],[2]], [5,8,2,9,1]); +nok array-formation([[1],[3]], [1,2,3]); +ok array-formation([[7,4,6]], [7,4,6]); +ok array-formation([[1,2,3],[4],[5,6],[1,2],[3,4,5]], [1,2,3,4,5,1,2,3,4,5,6]), "E Choroba Test"; + +sub array-formation(@source, @target) +{ + my $target = @target.Str; + + outer: for [X] @source.map({ 1..$target.match(/$_/, :g) }) -> $list + { + { + temp $target; + + for $list.kv -> $k,$v + { + $target .= subst(/"@source[$k]"/, 'X', :nth($v)); + next outer unless $/ + } + + return True unless $target ~~ /<digit>/ + } + } + + return False +} |
