diff options
| -rw-r--r-- | challenge-244/bruce-gray/raku/ch-1.raku | 15 | ||||
| -rw-r--r-- | challenge-244/bruce-gray/raku/ch-2.raku | 15 |
2 files changed, 30 insertions, 0 deletions
diff --git a/challenge-244/bruce-gray/raku/ch-1.raku b/challenge-244/bruce-gray/raku/ch-1.raku new file mode 100644 index 0000000000..f8893b7c34 --- /dev/null +++ b/challenge-244/bruce-gray/raku/ch-1.raku @@ -0,0 +1,15 @@ +sub task1 ( @ns ) { + return @ns.map: (@ns X< *).sum; +} + + +constant @tests = + ( (8, 1, 2, 2, 3) , (4, 0, 1, 1, 3) ), + ( (6, 5, 4, 8) , (2, 1, 0, 3) ), + ( (2, 2, 2) , (0, 0, 0) ), +; + +use Test; plan +@tests; +for @tests -> (@in, @expected) { + is-deeply task1(@in), @expected; +} diff --git a/challenge-244/bruce-gray/raku/ch-2.raku b/challenge-244/bruce-gray/raku/ch-2.raku new file mode 100644 index 0000000000..c133d601e8 --- /dev/null +++ b/challenge-244/bruce-gray/raku/ch-2.raku @@ -0,0 +1,15 @@ +sub task2 ( @strengths ) { + + sub power (@seq) { [*] @seq.minmax.bounds.[0,1,1] } + + return sum map &power, combinations(@strengths, 1..*); +} + + +constant @tests = + ( 141, (2, 1, 4) ), +; +use Test; plan +@tests; +for @tests -> ($expected, @in) { + is task2(@in), $expected; +} |
