diff options
| -rwxr-xr-x | challenge-244/feng-chang/raku/ch-1.raku | 5 | ||||
| -rwxr-xr-x | challenge-244/feng-chang/raku/ch-2.raku | 5 | ||||
| -rwxr-xr-x | challenge-244/feng-chang/raku/test.raku | 24 |
3 files changed, 34 insertions, 0 deletions
diff --git a/challenge-244/feng-chang/raku/ch-1.raku b/challenge-244/feng-chang/raku/ch-1.raku new file mode 100755 index 0000000000..f40b300083 --- /dev/null +++ b/challenge-244/feng-chang/raku/ch-1.raku @@ -0,0 +1,5 @@ +#!/bin/env raku + +unit sub MAIN(*@ints); + +put @ints.map({ +@ints.grep(* < $_) }); diff --git a/challenge-244/feng-chang/raku/ch-2.raku b/challenge-244/feng-chang/raku/ch-2.raku new file mode 100755 index 0000000000..ff9676ae26 --- /dev/null +++ b/challenge-244/feng-chang/raku/ch-2.raku @@ -0,0 +1,5 @@ +#!/bin/env raku + +unit sub MAIN(*@ints); + +put @ints.combinations(1..Inf).map({ .max² * .min }).sum; diff --git a/challenge-244/feng-chang/raku/test.raku b/challenge-244/feng-chang/raku/test.raku new file mode 100755 index 0000000000..3426425b6b --- /dev/null +++ b/challenge-244/feng-chang/raku/test.raku @@ -0,0 +1,24 @@ +#!/bin/env raku + +# The Weekly Challenge 244 +use Test; + +sub pwc-test(Str:D $script, Bool :$deeply? = False, *@input) { + my ($expect, $assertion) = @input.splice(*-2, 2); + my $p = run $script, |@input, :out; + if $deeply { + is-deeply $p.out.slurp(:close).chomp.words.Bag, $expect, $assertion; + } else { + is $p.out.slurp(:close).chomp, $expect, $assertion; + } +} + +# Task 1, Count Smaller +pwc-test './ch-1.raku', |<8 1 2 2 3>, '4 0 1 1 3', 'Count Smaller: @nums = (8, 1, 2, 2, 3) => (4, 0, 1, 1, 3)'; +pwc-test './ch-1.raku', |<6 5 4 8>, '2 1 0 3', 'Count Smaller: @nums = (6, 5, 4, 8) => (2, 1, 0, 3)'; +pwc-test './ch-1.raku', |<2 2 2>, '0 0 0', 'Count Smaller: @nums = (2, 2, 2) => (0, 0, 0)'; + +# Task 2, Group Hero +pwc-test './ch-2.raku', |<2 1 4>, 141, 'Group Hero: (2, 1, 4) => 141'; + +done-testing; |
