aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author冯昶 <fengchang@novel-supertv.com>2025-07-14 14:06:16 +0800
committer冯昶 <fengchang@novel-supertv.com>2025-07-14 14:06:16 +0800
commiteb9a9dae605d68178509e6c40ef834b03878bfbe (patch)
treec0ae20163102c7139011391085f23b4043895de3
parent6345c73edaafe1c1252e99cf8991c8fc27890445 (diff)
downloadperlweeklychallenge-club-eb9a9dae605d68178509e6c40ef834b03878bfbe.tar.gz
perlweeklychallenge-club-eb9a9dae605d68178509e6c40ef834b03878bfbe.tar.bz2
perlweeklychallenge-club-eb9a9dae605d68178509e6c40ef834b03878bfbe.zip
challenge 330, raku solutions
-rwxr-xr-xchallenge-330/feng-chang/raku/ch-1.raku6
-rwxr-xr-xchallenge-330/feng-chang/raku/ch-2.raku5
-rwxr-xr-xchallenge-330/feng-chang/raku/test.raku24
3 files changed, 35 insertions, 0 deletions
diff --git a/challenge-330/feng-chang/raku/ch-1.raku b/challenge-330/feng-chang/raku/ch-1.raku
new file mode 100755
index 0000000000..ec9e1fc52f
--- /dev/null
+++ b/challenge-330/feng-chang/raku/ch-1.raku
@@ -0,0 +1,6 @@
+#!/bin/env raku
+
+unit sub MAIN(Str:D $s is copy);
+
+$s .= subst(/<lower><digit>/) while $s.contains(/<digit>/);
+put $s;
diff --git a/challenge-330/feng-chang/raku/ch-2.raku b/challenge-330/feng-chang/raku/ch-2.raku
new file mode 100755
index 0000000000..337796a084
--- /dev/null
+++ b/challenge-330/feng-chang/raku/ch-2.raku
@@ -0,0 +1,5 @@
+#!/bin/env raku
+
+unit sub MAIN(Str:D $s);
+
+put $s.words.map({ .chars == 1|2 ?? .lc !! .tclc }).join(' ');
diff --git a/challenge-330/feng-chang/raku/test.raku b/challenge-330/feng-chang/raku/test.raku
new file mode 100755
index 0000000000..42cb7d8075
--- /dev/null
+++ b/challenge-330/feng-chang/raku/test.raku
@@ -0,0 +1,24 @@
+#!/bin/env raku
+
+# The Weekly Challenge 330
+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, Clear Digits
+pwc-test './ch-1.raku', 'cab12', 'c', 'Clear Digits: cab12 => c';
+pwc-test './ch-1.raku', 'xy99', '', 'Clear Digits: xy99 => ""';
+pwc-test './ch-1.raku', 'pa1erl', 'perl', 'Clear Digits: pa1erl => perl';
+
+# Task 2, Title Capital
+pwc-test './ch-2.raku', 'PERL IS gREAT', 'Perl is Great', 'Title Capital: PERL IS gREAT => Perl is Great';
+pwc-test './ch-2.raku', 'THE weekly challenge', 'The Weekly Challenge', 'Title Capital: THE weekly challenge => The Weekly Challenge';
+pwc-test './ch-2.raku', 'YoU ARE A stAR', 'You Are a Star', 'Title Capital: YoU ARE A stAR => You Are a Star';