aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Krňávek <Jan.Krnavek@gmail.com>2024-01-28 14:11:24 +0100
committerJan Krňávek <Jan.Krnavek@gmail.com>2024-01-28 14:11:24 +0100
commit6924a26f48ee36ecf82d9c7c67f47ef812bf3fe3 (patch)
tree648b3817aece6da93769db87c0226a6f75570a9e
parent0572781431dd24e9d928890cb886e592d5c7b685 (diff)
downloadperlweeklychallenge-club-6924a26f48ee36ecf82d9c7c67f47ef812bf3fe3.tar.gz
perlweeklychallenge-club-6924a26f48ee36ecf82d9c7c67f47ef812bf3fe3.tar.bz2
perlweeklychallenge-club-6924a26f48ee36ecf82d9c7c67f47ef812bf3fe3.zip
solutions week 253
-rw-r--r--challenge-253/wambash/raku/ch-1.raku16
-rw-r--r--challenge-253/wambash/raku/ch-2.raku32
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/;
+}