aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Krňávek <Jan.Krnavek@gmail.com>2024-05-26 23:30:53 +0200
committerJan Krňávek <Jan.Krnavek@gmail.com>2024-05-26 23:30:53 +0200
commitd57bcfb533ee877e368a34b73dda36110d42927f (patch)
tree98e06305cd647a6694c917afcd39d18db51c1923
parent570751c7b456ed09e986992c34b0e68fb5de6623 (diff)
downloadperlweeklychallenge-club-d57bcfb533ee877e368a34b73dda36110d42927f.tar.gz
perlweeklychallenge-club-d57bcfb533ee877e368a34b73dda36110d42927f.tar.bz2
perlweeklychallenge-club-d57bcfb533ee877e368a34b73dda36110d42927f.zip
solution week 270-1
-rw-r--r--challenge-270/wambash/raku/ch-1.raku23
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-270/wambash/raku/ch-1.raku b/challenge-270/wambash/raku/ch-1.raku
new file mode 100644
index 0000000000..7cf6ef93ff
--- /dev/null
+++ b/challenge-270/wambash/raku/ch-1.raku
@@ -0,0 +1,23 @@
+#!/usr/bin/env raku
+use v6.*;
+
+sub special-position (+@matrix) {
+ my $columns := ([Z^] @matrix).grep: *.so,:k;
+ my $rows := @matrix.grep: *.one,:k;
+
+ $rows X, $columns
+ andthen .grep: -> ($r, $c) { @matrix[$r;$c] }\
+ andthen .elems
+}
+
+multi MAIN (Bool :test($)!) {
+ use Test;
+ is-deeply special-position(<1 1 0>,<0 0 1>,<1 0 0>),1;
+ is-deeply special-position(<1 0 0>,<0 0 1>,<1 0 0>),1;
+ is-deeply special-position(<1 0 0>,<0 1 0>,<0 0 1>),3;
+ done-testing;
+}
+
+multi MAIN (+@matrix) {
+ say special-position @matrix.map( *.comb».Int)
+}