diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-11-30 11:01:01 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-30 11:01:01 +0000 |
| commit | 6a9a58786bdd66ad4dd3bc68d8d32ab939dfda0f (patch) | |
| tree | 3cb9d3a28a442704bd4b85fd8f9f5a175b95cb99 /challenge-088 | |
| parent | 947cf4546914ee3dbf513ea17c35dba6c1dd4dcd (diff) | |
| parent | 3344d7287b7c8ae3f007d3bf58421bbc4c981176 (diff) | |
| download | perlweeklychallenge-club-6a9a58786bdd66ad4dd3bc68d8d32ab939dfda0f.tar.gz perlweeklychallenge-club-6a9a58786bdd66ad4dd3bc68d8d32ab939dfda0f.tar.bz2 perlweeklychallenge-club-6a9a58786bdd66ad4dd3bc68d8d32ab939dfda0f.zip | |
Merge pull request #2885 from jeongoon/master
[ch-088/jeongoon] ch-2.raku had bug.. fixed.
Diffstat (limited to 'challenge-088')
| -rw-r--r-- | challenge-088/jeongoon/raku/ch-2.raku | 13 |
1 files 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; |
