From 3344d7287b7c8ae3f007d3bf58421bbc4c981176 Mon Sep 17 00:00:00 2001 From: Myoungjin JEON Date: Mon, 30 Nov 2020 21:09:34 +1100 Subject: [ch-088/jeongoon] ch-2.raku had bug.. fixed. --- challenge-088/jeongoon/raku/ch-2.raku | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/challenge-088/jeongoon/raku/ch-2.raku b/challenge-088/jeongoon/raku/ch-2.raku index d0b6626728..fb3964dfeb 100644 --- a/challenge-088/jeongoon/raku/ch-2.raku +++ b/challenge-088/jeongoon/raku/ch-2.raku @@ -18,7 +18,7 @@ unit sub MAIN; $*ERR.say("Input: (Ctrl-D or Ctrl-Z to finish to input.)"); my @matrix = do with my @lines = $*IN.lines { @lines = @lines. - split(/"]" \s* "\n"* | "\n"/). # split rows by newline or `]' + split(/"]" \s* "\n"* || "\n"/). # split rows by newline or `]' map( -> $ln { next if $ln eq ""; (S:g/ ^\s+ || '[' || \s+$ // with $ln). split(/\s+/).Array } ); @@ -36,14 +36,16 @@ my @matrix = do with my @lines = $*IN.lines { # confirm user input my $ww = @matrix>>.List.flat.max(*.chars).chars; -$*ERR.say( "given matrix: " ); -$*ERR.say( .map({sprintf("%*s", $ww, $_)}).Array ) for @matrix; -$*ERR.say; +#$*ERR.say( "given matrix: " ); +#$*ERR.say( .map({sprintf("%*s", $ww, $_)}).Array ) for @matrix; +#$*ERR.say; sub peel-off( @a ) { my ( $re, $ce ) = @a.end, @a[0].end; my @inside = @a[ 1 .. $re.pred; 1 .. $ce.pred ] // Empty; + @inside .= rotor($ce.pred).map(*.Array) if @inside; + my @outside = @a[ 0; * ]; # outside of top for ( [ 1 .. $re; $ce ], # outside of right @@ -57,7 +59,6 @@ sub peel-off( @a ) { last unless all( $rr.elems.so, $cr.elems.so ); # out of range @outside.append: @a[$rr[*]; $cr[*]]; } - @inside, @outside } @@ -72,4 +73,4 @@ repeat { } while ( @mat[0] andthen { .elems > 0} ); -@spiral.say; +@spiral.put; -- cgit