From d57bcfb533ee877e368a34b73dda36110d42927f Mon Sep 17 00:00:00 2001 From: Jan Krňávek Date: Sun, 26 May 2024 23:30:53 +0200 Subject: solution week 270-1 --- challenge-270/wambash/raku/ch-1.raku | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 challenge-270/wambash/raku/ch-1.raku 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) +} -- cgit