diff options
| author | Util <bruce.gray@acm.org> | 2022-09-04 15:59:58 -0500 |
|---|---|---|
| committer | Util <bruce.gray@acm.org> | 2022-09-04 15:59:58 -0500 |
| commit | e67a6703eb0b6750672b3c0ed14e4b35d3f8c2a0 (patch) | |
| tree | f36f86f2137913fdcd49a644e5b950f3bd8da51a | |
| parent | 21a64d689ff2e6d2b1898dd580bee8582b207137 (diff) | |
| download | perlweeklychallenge-club-e67a6703eb0b6750672b3c0ed14e4b35d3f8c2a0.tar.gz perlweeklychallenge-club-e67a6703eb0b6750672b3c0ed14e4b35d3f8c2a0.tar.bz2 perlweeklychallenge-club-e67a6703eb0b6750672b3c0ed14e4b35d3f8c2a0.zip | |
Add TWC 180 solutions by Bruce Gray : Raku only.
| -rw-r--r-- | challenge-180/bruce-gray/raku/ch-1.raku | 14 | ||||
| -rw-r--r-- | challenge-180/bruce-gray/raku/ch-2.raku | 13 |
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; +} |
