diff options
| author | 冯昶 <fengchang@novel-supertv.com> | 2024-06-24 17:35:50 +0800 |
|---|---|---|
| committer | 冯昶 <fengchang@novel-supertv.com> | 2024-06-24 17:35:50 +0800 |
| commit | 8a4ca153cebf203e1849bddd21beef4711474d70 (patch) | |
| tree | b11b4f0fa2001a84da779c9733082a959d51641b /challenge-275 | |
| parent | e706d2548a3ce7ff5d3ae480224ee3ee6c5577de (diff) | |
| download | perlweeklychallenge-club-8a4ca153cebf203e1849bddd21beef4711474d70.tar.gz perlweeklychallenge-club-8a4ca153cebf203e1849bddd21beef4711474d70.tar.bz2 perlweeklychallenge-club-8a4ca153cebf203e1849bddd21beef4711474d70.zip | |
challenge 275, raku solutions
Diffstat (limited to 'challenge-275')
| -rwxr-xr-x | challenge-275/feng-chang/raku/ch-1.raku | 6 | ||||
| -rwxr-xr-x | challenge-275/feng-chang/raku/ch-2.raku | 10 | ||||
| -rwxr-xr-x | challenge-275/feng-chang/raku/test.raku | 26 |
3 files changed, 42 insertions, 0 deletions
diff --git a/challenge-275/feng-chang/raku/ch-1.raku b/challenge-275/feng-chang/raku/ch-1.raku new file mode 100755 index 0000000000..9dd4df3d57 --- /dev/null +++ b/challenge-275/feng-chang/raku/ch-1.raku @@ -0,0 +1,6 @@ +#!/bin/env raku + +unit sub MAIN(*@words); + +my @broken = @words.tail.lc.comb; +put +@words.grep(*.lc.comb.any ne @broken.any); diff --git a/challenge-275/feng-chang/raku/ch-2.raku b/challenge-275/feng-chang/raku/ch-2.raku new file mode 100755 index 0000000000..ef35e4272f --- /dev/null +++ b/challenge-275/feng-chang/raku/ch-2.raku @@ -0,0 +1,10 @@ +#!/bin/env raku + +unit sub MAIN(Str:D $s); + +my $c; +for $s.comb { + when 0..9 { print ($c.ord + $_).chr } + default { $c = $_; .print } +} +put ''; diff --git a/challenge-275/feng-chang/raku/test.raku b/challenge-275/feng-chang/raku/test.raku new file mode 100755 index 0000000000..8d88f59ff9 --- /dev/null +++ b/challenge-275/feng-chang/raku/test.raku @@ -0,0 +1,26 @@ +#!/bin/env raku + +# The Weekly Challenge 275 +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, Broken Keys +pwc-test './ch-1.raku', <Perl Weekly Challenge>, 'la', 0, 'Broken Keys: "Perl Weekly Challenge", <l a> => 0'; +pwc-test './ch-1.raku', <Perl and Raku>, 'a', 1, 'Broken Keys: "Perl and Raku", <a> => 1'; +pwc-test './ch-1.raku', <Well done Team PWC>, 'lo', 2, 'Broken Keys: "Well done Team PWC", <l o> => 2'; +pwc-test './ch-1.raku', <The joys of polyglottism>, 'T', 2, 'Broken Keys: "The joys of polyglottism", <T> => 2'; + +# Task 2, Replace Digits +pwc-test './ch-2.raku', 'a1c1e1', 'abcdef', 'Replace Digits: "a1c1e1" => "abcdef"'; +pwc-test './ch-2.raku', 'a1b2c3d4', 'abbdcfdh', 'Replace Digits: "a1b2c3d4" => "abbdcfdh"'; +pwc-test './ch-2.raku', 'b2b', 'bdb', 'Replace Digits: "b2b" => "bdb"'; +pwc-test './ch-2.raku', 'a16z', 'abgz', 'Replace Digits: "a16z" => "abgz"'; |
