aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-180/bruce-gray/raku/ch-1.raku14
-rw-r--r--challenge-180/bruce-gray/raku/ch-2.raku13
2 files changed, 27 insertions, 0 deletions
diff --git a/challenge-180/bruce-gray/raku/ch-1.raku b/challenge-180/bruce-gray/raku/ch-1.raku
new file mode 100644
index 0000000000..73ce6f55e9
--- /dev/null
+++ b/challenge-180/bruce-gray/raku/ch-1.raku
@@ -0,0 +1,14 @@
+sub first_unique_character_index ( Str $_ --> UInt ) {
+ my @c = .lc.comb;
+ my %h = @c.repeated.Set;
+ return @c.first: :k, * !~~ %h;
+}
+
+my @tests =
+ 'Perl Weekly Challenge' => 0,
+ 'Long Live Perl' => 1,
+ 'abc abc' => 3,
+;
+use Test;
+plan +@tests;
+is first_unique_character_index(.key), .value for @tests;
diff --git a/challenge-180/bruce-gray/raku/ch-2.raku b/challenge-180/bruce-gray/raku/ch-2.raku
new file mode 100644
index 0000000000..55d7c638cc
--- /dev/null
+++ b/challenge-180/bruce-gray/raku/ch-2.raku
@@ -0,0 +1,13 @@
+sub trim_list ( $i, @n ) {
+ return @n.grep: * > $i;
+}
+
+my @tests =
+ ( 3, (1,4,2,3,5) , (4,5) ),
+ ( 4, (9,0,6,2,3,8,5) , (9,6,8,5) ),
+;
+use Test;
+plan +@tests;
+for @tests -> ( $i, $n, $expected ) {
+ is-deeply trim_list($i, $n), $expected;
+}