aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Ferrari <fluca1978@gmail.com>2021-08-30 10:34:26 +0200
committerLuca Ferrari <fluca1978@gmail.com>2021-08-30 10:34:26 +0200
commitefe18c028ec89274497049eb1ed8a76d37863483 (patch)
treed8957aa1070c22c1e2015c9dc995c91b47ba86a2
parent903abdef122a8081f238f0b3a9e8c02c5929b2b8 (diff)
downloadperlweeklychallenge-club-efe18c028ec89274497049eb1ed8a76d37863483.tar.gz
perlweeklychallenge-club-efe18c028ec89274497049eb1ed8a76d37863483.tar.bz2
perlweeklychallenge-club-efe18c028ec89274497049eb1ed8a76d37863483.zip
Task 1 done
-rw-r--r--challenge-128/luca-ferrari/raku/ch-1.p659
1 files changed, 59 insertions, 0 deletions
diff --git a/challenge-128/luca-ferrari/raku/ch-1.p6 b/challenge-128/luca-ferrari/raku/ch-1.p6
new file mode 100644
index 0000000000..180ce1ba7a
--- /dev/null
+++ b/challenge-128/luca-ferrari/raku/ch-1.p6
@@ -0,0 +1,59 @@
+#!raku
+
+sub MAIN() {
+ my @matrix = [ 1 ,0, 0, 0, 1, 0 ],
+ [ 1 ,1, 0, 0, 0, 1 ],
+ [ 1, 0, 0, 0, 0, 0 ];
+
+ my @zeroes;
+
+ for 0 ..^ @matrix.elems -> $current-row {
+ for 0 ..^ @matrix[ $current-row ].elems -> $current-column {
+ my $zeroes-count = 0;
+ my $column = $current-column;
+ my $previous-column = $current-column;
+ while ( $column < @matrix[ $current-row ].elems && $column - $previous-column <= 1 ) {
+ $zeroes-count++ if @matrix[ $current-row ][ $column ] == 0;
+ last if @matrix[ $current-row ][ $column ] != 0;
+ $previous-column = $column++;
+ }
+
+ @zeroes[ $current-row ][ $current-column ] = $zeroes-count;
+ }
+ }
+
+ say @zeroes;
+
+ my $rows = 0;
+ my $cols = 0;
+ my @sub-matrix;
+ my $max = 0;
+ for 0 ..^ @zeroes.elems -> $current-row {
+ for 0 ..^ @zeroes[ $current-row ].elems -> $current-column {
+ next if @zeroes[ $current-row ][ $current-column ] == 0;
+ $cols = @zeroes[ $current-row ][ $current-column ];
+ $rows = 1;
+
+
+ for $current-row + 1 ..^ @zeroes.elems -> $next-row {
+ $rows = 0 and last if @zeroes[ $next-row ][ $current-column ] == 0;
+ $rows++ if @zeroes[ $next-row ][ $current-column ] != 0;
+ $cols = min( $cols, @zeroes[ $next-row ][ $current-column ] );
+ }
+
+
+ $max = $rows * $cols if $rows * $cols > $max;
+ @sub-matrix.push: [ $rows * $cols, $current-row, $current-column, $current-row + $rows - 1, $current-column + $cols - 1 ] if $rows * $cols > 0 && $rows * $cols >= $max;
+
+
+
+
+ }
+ }
+
+ "{ $_[ 0 ] } zeroes starting from <{ $_[ 1 ] }, { $_[ 2 ]}> to <{ $_[ 3 ] }, { $_[ 4 ]}>".say for @sub-matrix;
+
+
+
+
+}