From c0ed66161cb9372d01302da905ae15e7d3916a3c Mon Sep 17 00:00:00 2001 From: Mark <53903062+andemark@users.noreply.github.com> Date: Mon, 19 Feb 2024 14:38:45 +0000 Subject: Challenge 257 Solutions (Raku) --- challenge-257/mark-anderson/raku/ch-2.raku | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/challenge-257/mark-anderson/raku/ch-2.raku b/challenge-257/mark-anderson/raku/ch-2.raku index 5492722dcc..1dc1835310 100644 --- a/challenge-257/mark-anderson/raku/ch-2.raku +++ b/challenge-257/mark-anderson/raku/ch-2.raku @@ -36,14 +36,15 @@ sub reduced-row-echelon(+@m) # the first non-zero number in a row is the pivot my @pivots = @m>>.first(*.so, :kv); - # find the first row that is all zeroes - my $k = @pivots.first(*.so.not, :k); + # the first row that is all zeroes + my $k = @pivots.first(*.not, :k); # all 0 rows are grouped at the bottom - if $k { - return False unless @pivots[$k..*].all eqv Any; - @pivots = @pivots[^$k] - } + if $k + { + return False unless @pivots[$k..*].all eqv Any; + @pivots = @pivots[^$k] + } # all pivots == 1 return False unless so @pivots>>.[1].all == 1; @@ -53,7 +54,7 @@ sub reduced-row-echelon(+@m) # pivot columns are all 0 (except for the 1) return all @pivots>>[0].map({ - all @m[*;$_].sum == 1, - all(@m[*;$_].Bag.keys) ~~ 0..1 - }) + all @m[*;$_].sum == 1, + all(@m[*;$_].Bag.keys) ~~ 0..1 + }) } -- cgit