diff options
| -rw-r--r-- | challenge-253/wambash/raku/ch-1.raku | 16 | ||||
| -rw-r--r-- | challenge-253/wambash/raku/ch-2.raku | 32 |
2 files changed, 48 insertions, 0 deletions
diff --git a/challenge-253/wambash/raku/ch-1.raku b/challenge-253/wambash/raku/ch-1.raku new file mode 100644 index 0000000000..8bb99a0cfd --- /dev/null +++ b/challenge-253/wambash/raku/ch-1.raku @@ -0,0 +1,16 @@ +#!/usr/bin/env raku + +sub split-string (+words, :$separator=q{ }) { + words.map: |*.split($separator, :skip-empty ) +} + +multi MAIN (Bool :test($)!) { + use Test; + is-deeply split-string(<one.two.three four.five six>):separator('.'), <one two three four five six>; + is-deeply split-string(<$perl$$ $$raku$>):separator('$'),<perl raku>; + done-testing; +} + +multi MAIN (+words, :$separator=q{ }) { + put split-string words, :$separator +} diff --git a/challenge-253/wambash/raku/ch-2.raku b/challenge-253/wambash/raku/ch-2.raku new file mode 100644 index 0000000000..f48df8ca77 --- /dev/null +++ b/challenge-253/wambash/raku/ch-2.raku @@ -0,0 +1,32 @@ +#!/usr/bin/env raku + +sub weekest-row (+matrix) { + matrix + andthen .antipairs + andthen .sort + andthen .map: *.value +} + +multi MAIN (Bool :test($)!) { + use Test; + my @matrix := [ + [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] + ]; + is weekest-row(@matrix),(2,0,3,1,4); + my @matrix2 := [ + [1, 0, 0, 0], + [1, 1, 1, 1], + [1, 0, 0, 0], + [1, 0, 0, 0] + ]; + is weekest-row(@matrix2), (0,2,3,1); + done-testing; +} + +multi MAIN (+matrix) { + put weekest-row matrix».comb: /\d/; +} |
