diff options
| author | Util <bruce.gray@acm.org> | 2024-02-18 11:11:43 -0600 |
|---|---|---|
| committer | Util <bruce.gray@acm.org> | 2024-02-18 11:11:43 -0600 |
| commit | ccede10dd378a41437ea873814cd30107e017378 (patch) | |
| tree | 7ceefac5dc9e8f45df455eeb9bdf85776d68df7d | |
| parent | ea7a39e00664462772534988dd02a7b6e658afa2 (diff) | |
| download | perlweeklychallenge-club-ccede10dd378a41437ea873814cd30107e017378.tar.gz perlweeklychallenge-club-ccede10dd378a41437ea873814cd30107e017378.tar.bz2 perlweeklychallenge-club-ccede10dd378a41437ea873814cd30107e017378.zip | |
Add TWC 256 solutions by Bruce Gray, in Raku only.
| -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; +} |
