aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-275/bruce-gray/raku/ch-1.raku18
-rw-r--r--challenge-275/bruce-gray/raku/ch-2.raku19
2 files changed, 37 insertions, 0 deletions
diff --git a/challenge-275/bruce-gray/raku/ch-1.raku b/challenge-275/bruce-gray/raku/ch-1.raku
new file mode 100644
index 0000000000..2131172a29
--- /dev/null
+++ b/challenge-275/bruce-gray/raku/ch-1.raku
@@ -0,0 +1,18 @@
+sub task1 ( @broken_keys, Str $sentence --> UInt ) {
+ my @w = $sentence.lc.words;
+
+ my $bk = @broken_keys».lc.Set;
+
+ return +grep { !( .comb ∩ $bk ) }, @w;
+}
+
+
+use Test; plan +my @tests =
+ ( 0, 'la' , 'Perl Weekly Challenge' ),
+ ( 1, 'a' , 'Perl and Raku' ),
+ ( 2, 'lo' , 'Well done Team PWC' ),
+ ( 2, 'T' , 'The joys of polyglottism' ),
+;
+for @tests -> ( $expected, $in_keys, $in_sentence ) {
+ is task1($in_keys.comb, $in_sentence), $expected;
+}
diff --git a/challenge-275/bruce-gray/raku/ch-2.raku b/challenge-275/bruce-gray/raku/ch-2.raku
new file mode 100644
index 0000000000..89fc2cc6aa
--- /dev/null
+++ b/challenge-275/bruce-gray/raku/ch-2.raku
@@ -0,0 +1,19 @@
+sub task2 ( Str $s --> Str ) {
+ my $prior_char;
+
+ return [~] gather for $s.comb {
+ if /<.alpha>/ { take $prior_char = $_ }
+ else { take chr( $_ + $prior_char.ord ) }
+ }
+}
+
+
+use Test; plan +my @tests =
+ <a1c1e1 abcdef>,
+ <a1b2c3d4 abbdcfdh>,
+ <b2b bdb>,
+ <a16z abgz>,
+;
+for @tests -> ( $in, $expected ) {
+ is task2($in), $expected;
+}