diff options
| author | Mark <53903062+andemark@users.noreply.github.com> | 2024-01-22 08:23:35 +0000 |
|---|---|---|
| committer | Mark <53903062+andemark@users.noreply.github.com> | 2024-01-22 08:23:35 +0000 |
| commit | 2c2d463c2eaea9d6bba26e3fcc4be2ad48a29c21 (patch) | |
| tree | 2b8d8082ac552ed01de685aedffcbc664f6a70fd | |
| parent | 9d7dc816f7775abfee7d90f0a2a969611902be54 (diff) | |
| download | perlweeklychallenge-club-2c2d463c2eaea9d6bba26e3fcc4be2ad48a29c21.tar.gz perlweeklychallenge-club-2c2d463c2eaea9d6bba26e3fcc4be2ad48a29c21.tar.bz2 perlweeklychallenge-club-2c2d463c2eaea9d6bba26e3fcc4be2ad48a29c21.zip | |
Challenge 253 Solutions (Raku)
| -rw-r--r-- | challenge-253/mark-anderson/raku/ch-1.raku | 13 | ||||
| -rw-r--r-- | challenge-253/mark-anderson/raku/ch-2.raku | 33 |
2 files changed, 46 insertions, 0 deletions
diff --git a/challenge-253/mark-anderson/raku/ch-1.raku b/challenge-253/mark-anderson/raku/ch-1.raku new file mode 100644 index 0000000000..0b4b73fcde --- /dev/null +++ b/challenge-253/mark-anderson/raku/ch-1.raku @@ -0,0 +1,13 @@ +#!/usr/bin/env raku +use Test; + +is-deeply split-strings(<one.two.three four.five six>, '.'), + <one two three four five six>; + +is-deeply split-strings(<$perl$$ $$raku$>, '$'), + <perl raku>; + +sub split-strings(@a, $separator) +{ + flat @a>>.split($separator, :skip-empty) +} diff --git a/challenge-253/mark-anderson/raku/ch-2.raku b/challenge-253/mark-anderson/raku/ch-2.raku new file mode 100644 index 0000000000..1a581b0901 --- /dev/null +++ b/challenge-253/mark-anderson/raku/ch-2.raku @@ -0,0 +1,33 @@ +#!/usr/bin/env raku +use Test; + +is-deeply weakest-rows([ + [1, 1, 0, 0, 0], + [1, 1, 1, 1, 0], + [1, 0, 0, 0, 0], + [1, 1, 0, 0, 0], + [1, 1, 1, 1, 1] + ]), + (2, 0, 3, 1, 4); + +is-deeply weakest-rows([ + [1, 0, 0, 0], + [1, 1, 1, 1], + [1, 0, 0, 0], + [1, 0, 0, 0] + ]), + (0, 2, 3, 1); + +is-deeply weakest-rows([ + [1, 1, 0, 0, 0], + [1, 1, 1, 1, 0], + [0, 0, 0, 0, 0], + [1, 1, 0, 0, 0], + [1, 1, 1, 1, 1] + ]), + (2, 0, 3, 1, 4); + +sub weakest-rows($m) +{ + $m.map({ .first(0, :k) // ∞ }).antipairs.sort>>.value +} |
