diff options
| author | 冯昶 <fengchang@novel-supertv.com> | 2023-10-23 15:51:36 +0800 |
|---|---|---|
| committer | 冯昶 <fengchang@novel-supertv.com> | 2023-10-23 15:51:36 +0800 |
| commit | 7fe999f4ae6a14b7f3497f06eaa936c6fcbe6436 (patch) | |
| tree | 4b23df88715b5653e180280ee72a874fff6ff9d3 | |
| parent | 595d92e7e979a5c6d56f128b0c2afe5ea84afda2 (diff) | |
| download | perlweeklychallenge-club-7fe999f4ae6a14b7f3497f06eaa936c6fcbe6436.tar.gz perlweeklychallenge-club-7fe999f4ae6a14b7f3497f06eaa936c6fcbe6436.tar.bz2 perlweeklychallenge-club-7fe999f4ae6a14b7f3497f06eaa936c6fcbe6436.zip | |
challenge 240, raku solutions
| -rwxr-xr-x | challenge-240/feng-chang/raku/ch-1.raku | 6 | ||||
| -rwxr-xr-x | challenge-240/feng-chang/raku/ch-2.raku | 5 | ||||
| -rwxr-xr-x | challenge-240/feng-chang/raku/test.raku | 25 |
3 files changed, 36 insertions, 0 deletions
diff --git a/challenge-240/feng-chang/raku/ch-1.raku b/challenge-240/feng-chang/raku/ch-1.raku new file mode 100755 index 0000000000..3a261225cc --- /dev/null +++ b/challenge-240/feng-chang/raku/ch-1.raku @@ -0,0 +1,6 @@ +#!/bin/env raku + +unit sub MAIN(*@words); + +my $chk = @words.pop; +put $chk.lc eq @words.map(*.substr(0,1)).join.lc; diff --git a/challenge-240/feng-chang/raku/ch-2.raku b/challenge-240/feng-chang/raku/ch-2.raku new file mode 100755 index 0000000000..cbf00739b8 --- /dev/null +++ b/challenge-240/feng-chang/raku/ch-2.raku @@ -0,0 +1,5 @@ +#!/bin/env raku + +unit sub MAIN(*@ints); + +put (^+@ints).map({ @ints[@ints[$_]] }); diff --git a/challenge-240/feng-chang/raku/test.raku b/challenge-240/feng-chang/raku/test.raku new file mode 100755 index 0000000000..5d8682ecbc --- /dev/null +++ b/challenge-240/feng-chang/raku/test.raku @@ -0,0 +1,25 @@ +#!/bin/env raku + +# The Weekly Challenge 240 +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, Acronym +pwc-test './ch-1.raku', |<Perl Python Pascal>, 'ppp', 'True', 'Acronym: @str = "Perl", "Python", "Pascal", $chk = "ppp" => True'; +pwc-test './ch-1.raku', |<Perl Raku>, 'rp', 'False', 'Acronym: @str = "Perl", "Raku", $chk = "rp" => False'; +pwc-test './ch-1.raku', |<Oracle Awk C>, 'oac', 'True', 'Acronym: @str = "Oracle", "Awk", "C", $chk = "oac" => True'; + +# Task 2, Build Array +pwc-test './ch-2.raku', |<0 2 1 5 3 4>, '0 1 2 4 5 3', 'Build Array: (0, 2, 1, 5, 3, 4) => "0 1 2 4 5 3"'; +pwc-test './ch-2.raku', |<5 0 1 2 3 4>, '4 5 0 1 2 3', 'Build Array: (5, 0, 1, 2, 3, 4) => "4 5 0 1 2 3"'; + +done-testing; |
