diff options
| author | rir <rirans@comcast.net> | 2024-06-30 15:47:06 -0400 |
|---|---|---|
| committer | rir <rirans@comcast.net> | 2024-06-30 15:48:04 -0400 |
| commit | 00a45ff36267e1da6094b48b8fac0a684658427d (patch) | |
| tree | 37a7f867d84c982e4c23ee18427658341afe0a31 | |
| parent | c83cd78b6b27af77bd4f1d71c01e2030b5034394 (diff) | |
| download | perlweeklychallenge-club-00a45ff36267e1da6094b48b8fac0a684658427d.tar.gz perlweeklychallenge-club-00a45ff36267e1da6094b48b8fac0a684658427d.tar.bz2 perlweeklychallenge-club-00a45ff36267e1da6094b48b8fac0a684658427d.zip | |
275
| -rw-r--r-- | challenge-275/0rir/raku/ch-1.raku | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/challenge-275/0rir/raku/ch-1.raku b/challenge-275/0rir/raku/ch-1.raku new file mode 100644 index 0000000000..54d37d4665 --- /dev/null +++ b/challenge-275/0rir/raku/ch-1.raku @@ -0,0 +1,54 @@ +#!/usr/bin/env raku +# :vim ft=raku sw=4 expandtab # 🦋 ∅∪∩∋∈∉⊆ ≡ ≢ « » ∴ +use v6.d; +use Test; + +=begin comment +Task 1: Broken Keys +Submitted by: Mohammad Sajid Anwar +You are given a sentence, $sentence and list of broken keys @keys. + +Write a script to find out how many words can be typed fully. + +Example 1 +Input: $sentence = "Perl Weekly Challenge", @keys = ('l', 'a') +Output: 0 +Example 2 +Input: $sentence = "Perl and Raku", @keys = ('a') +Output: 1 + +Only Perl since the other word two words contain 'a' and can't be typed fully. +Example 3 +Input: $sentence = "Well done Team PWC", @keys = ('l', 'o') +Output: 2 +Example 4 +Input: $sentence = "The joys of polyglottism", @keys = ('T') +Output: 2 +=end comment + +my @Test = + # words disease healthy count + "Perl and Raku", ('a',), 1, + "Perl Weekly Challenge", ('l', 'a'), 0, + "Well done Team PWC", ('l', 'o'), 2, + "The joys of polyglottism", ('T',), 2, + "The horrors of babel", (), 4, + +; +plan @Test ÷ 3; + +only task( $sentence is copy, @poison --> Int) { + + $sentence.words».contains( /:ignorecase @poison /).grep( !*); +} + +for @Test -> $in, @poison, $exp { + is task($in, @poison), $exp, "$exp <- $in [ @poison[]]"; +} + +done-testing; + +my $sentence = "Perl and Raku"; +my @key = ('p',); + +say qq{\nInput: \$sentence = "Perl and Raku", @keys = @key[]\n} + ~ "Output: ", task $sentence, @key; |
