From 03be81377fc1ec1962e44e713f2cc9081da9c2f9 Mon Sep 17 00:00:00 2001 From: BarrOff <58253563+BarrOff@users.noreply.github.com> Date: Sun, 26 Oct 2025 23:48:57 +0100 Subject: feat: add solution for challenge 344 from BarrOff --- challenge-344/barroff/raku/ch-2.p6 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 challenge-344/barroff/raku/ch-2.p6 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])"'; +} -- cgit