diff options
| -rw-r--r-- | challenge-256/bruce-gray/raku/ch-1.raku | 14 | ||||
| -rw-r--r-- | challenge-256/bruce-gray/raku/ch-2.raku | 21 |
2 files changed, 35 insertions, 0 deletions
diff --git a/challenge-256/bruce-gray/raku/ch-1.raku b/challenge-256/bruce-gray/raku/ch-1.raku new file mode 100644 index 0000000000..5b94d23987 --- /dev/null +++ b/challenge-256/bruce-gray/raku/ch-1.raku @@ -0,0 +1,14 @@ +sub task1 ( @words --> UInt ) { + return +grep { .[0] eq .[1].flip }, + combinations(@words, 2); +} + + +use Test; plan +my @tests = + ( 1, <ab de ed bc> ), + ( 0, <aa ba cd ed> ), + ( 2, <uv qp st vu mn pq> ), +; +for @tests -> ( $expected, @in ) { + is task1(@in), $expected; +} diff --git a/challenge-256/bruce-gray/raku/ch-2.raku b/challenge-256/bruce-gray/raku/ch-2.raku new file mode 100644 index 0000000000..6d9ccce81e --- /dev/null +++ b/challenge-256/bruce-gray/raku/ch-2.raku @@ -0,0 +1,21 @@ +sub task2 { [~] roundrobin :slip, ($^a, $^b)ยป.comb } + +sub task2_before_slip_in_roundrobin_2022_02 ( Str $a, Str $b --> Str ) { + my @a = $a.comb; + my @b = $b.comb; + + @a.append: '' xx (@b - @a); + @b.append: '' xx (@a - @b); + + return [~] @a Z~ @b; +} + + +use Test; plan +my @tests = + <abcd 1234 a1b2c3d4>, + <abc 12345 a1b2c345>, + <abcde 123 a1b2c3de>, +; +for @tests -> ( $in1, $in2, $expected ) { + is task2($in1, $in2), $expected; +} |
