diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2024-06-24 22:25:00 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-24 22:25:00 +0100 |
| commit | 6e57cc6b0779f09bb1bcf486a002cd8b0d38993f (patch) | |
| tree | 91a8f796e320b444de66aac267ba632113dd9d01 | |
| parent | 2238c4c5cca4d1e4ac7a607cba7b764ab3f73279 (diff) | |
| parent | 8a4ca153cebf203e1849bddd21beef4711474d70 (diff) | |
| download | perlweeklychallenge-club-6e57cc6b0779f09bb1bcf486a002cd8b0d38993f.tar.gz perlweeklychallenge-club-6e57cc6b0779f09bb1bcf486a002cd8b0d38993f.tar.bz2 perlweeklychallenge-club-6e57cc6b0779f09bb1bcf486a002cd8b0d38993f.zip | |
Merge pull request #10313 from seaker/master
challenge 275, raku solutions
| -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"'; |
