aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-255/feng-chang/raku/ch-1.raku5
-rwxr-xr-xchallenge-255/feng-chang/raku/ch-2.raku7
-rwxr-xr-xchallenge-255/feng-chang/raku/test.raku33
3 files changed, 45 insertions, 0 deletions
diff --git a/challenge-255/feng-chang/raku/ch-1.raku b/challenge-255/feng-chang/raku/ch-1.raku
new file mode 100755
index 0000000000..e2e64ec169
--- /dev/null
+++ b/challenge-255/feng-chang/raku/ch-1.raku
@@ -0,0 +1,5 @@
+#!/bin/env raku
+
+unit sub MAIN(Str:D $s, Str:D $t);
+
+put ($t.comb.Bag (-) $s.comb.Bag).first.key;
diff --git a/challenge-255/feng-chang/raku/ch-2.raku b/challenge-255/feng-chang/raku/ch-2.raku
new file mode 100755
index 0000000000..0422ceadf8
--- /dev/null
+++ b/challenge-255/feng-chang/raku/ch-2.raku
@@ -0,0 +1,7 @@
+#!/bin/env raku
+
+unit sub MAIN(Str:D $snt, Str:D $banned);
+
+my %words is BagHash = $snt.comb(/\w+/);
+%words{$banned}:delete;
+put %words.sort(-*.value).first.key;
diff --git a/challenge-255/feng-chang/raku/test.raku b/challenge-255/feng-chang/raku/test.raku
new file mode 100755
index 0000000000..228b30b9d8
--- /dev/null
+++ b/challenge-255/feng-chang/raku/test.raku
@@ -0,0 +1,33 @@
+#!/bin/env raku
+
+# The Weekly Challenge 254
+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, Odd Character
+pwc-test './ch-1.raku', <Perl Preel>, 'e', 'Odd Character: "Perl", "Preel" => "e"';
+pwc-test './ch-1.raku', <Weekly Weeakly>, 'a', 'Odd Character: "Weekly", "Weeakly" => "a"';
+pwc-test './ch-1.raku', <Box Boxy>, 'y', 'Odd Character: "Box", "Boxy" => "y"';
+
+# Task 2, Most Frequent Word
+pwc-test './ch-2.raku',
+ "Joe hit a ball, the hit ball flew far after it was hit.",
+ 'hit',
+ 'ball',
+ 'Most Frequent Word: "Joe hit a ball, the hit ball flew far after it was hit." => ball';
+pwc-test './ch-2.raku',
+ "Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge.",
+ 'the',
+ 'Perl',
+ 'Most Frequent Word: "Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge." => Perl';
+
+done-testing;