diff options
| author | BarrOff <58253563+BarrOff@users.noreply.github.com> | 2025-10-05 22:19:25 +0200 |
|---|---|---|
| committer | BarrOff <58253563+BarrOff@users.noreply.github.com> | 2025-10-05 22:19:25 +0200 |
| commit | 795cab8f4f97b34c72c3f736258cb05b151ef625 (patch) | |
| tree | 9174d5cea4684ec07cbf3bb7b99d698b3fce1c7f | |
| parent | a64570c2601b4fec8f117fd49cd0fd41523d0b3b (diff) | |
| download | perlweeklychallenge-club-795cab8f4f97b34c72c3f736258cb05b151ef625.tar.gz perlweeklychallenge-club-795cab8f4f97b34c72c3f736258cb05b151ef625.tar.bz2 perlweeklychallenge-club-795cab8f4f97b34c72c3f736258cb05b151ef625.zip | |
feat: add solution for challenge 341 from BarrOff
| -rw-r--r-- | challenge-341/barroff/raku/ch-1.p6 | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/challenge-341/barroff/raku/ch-1.p6 b/challenge-341/barroff/raku/ch-1.p6 new file mode 100644 index 0000000000..500cf3d690 --- /dev/null +++ b/challenge-341/barroff/raku/ch-1.p6 @@ -0,0 +1,28 @@ +#!/usr/bin/env raku + +use v6.d; + +sub broken-keyboard(Str $str, @keys --> Int) { + my $key-set = Set(map(&lc,@keys)); + grep({ $key-set (&) Set($_.comb) == ∅ }, $str.lc.words).elems; +} + +#| Run test cases +multi sub MAIN('test') { + use Test; + plan 5; + + is broken-keyboard("Hello World", ['d']), 1, 'works for "Hello World"'; + is broken-keyboard("apple banana cherry", ['a', 'e']), 0, + 'works for "apple banana cherry"'; + is broken-keyboard("Coding is fun", []), 3, 'works for "Coding is fun"'; + is broken-keyboard("The Weekly Challenge", ['a', 'b']), 2, + 'works for "The Weekly Challenge"'; + is broken-keyboard("Perl and Python", ['p']), 1, + 'works for "Perl and Python"'; +} + +#| Take user provided number like "Perl Weekly Challenge" l a +multi sub MAIN(Str $sentence, *@keys) { + say broken-keyboard($sentence, @keys); +} |
