diff options
| -rw-r--r-- | challenge-270/wambash/raku/ch-1.raku | 23 |
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) +} |
