diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-09-06 03:24:30 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-09-06 03:24:30 +0100 |
| commit | 5b5231d3f7f2310127c83a9c3167adb8749c9adc (patch) | |
| tree | 0533163f5c2833f28744a428fe0475fc25182964 | |
| parent | 3c0963531c095bb8885cc0aae7708110d16b109a (diff) | |
| download | perlweeklychallenge-club-5b5231d3f7f2310127c83a9c3167adb8749c9adc.tar.gz perlweeklychallenge-club-5b5231d3f7f2310127c83a9c3167adb8749c9adc.tar.bz2 perlweeklychallenge-club-5b5231d3f7f2310127c83a9c3167adb8749c9adc.zip | |
- Added solution by Colin Crain.
| -rwxr-xr-x | challenge-128/colin-crain/perl/ch-1.pl | 129 | ||||
| -rw-r--r-- | stats/pwc-current.json | 359 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 52 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 834 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 764 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 48 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 102 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 36 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 36 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 110 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 34 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 34 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 50 |
14 files changed, 1386 insertions, 1242 deletions
diff --git a/challenge-128/colin-crain/perl/ch-1.pl b/challenge-128/colin-crain/perl/ch-1.pl new file mode 100755 index 0000000000..9270b07561 --- /dev/null +++ b/challenge-128/colin-crain/perl/ch-1.pl @@ -0,0 +1,129 @@ +#!/Users/colincrain/perl5/perlbrew/perls/perl-5.32.0/bin/perl
+#
+# .pl
+#
+# Maximum Sub-Matrix
+# Submitted by: Mohammad S Anwar
+# You are given m x n binary matrix having 0 or 1.
+#
+# Write a script to find out maximum sub-matrix having only 0.
+#
+# Example 1:
+# Input : [ 1 0 0 0 1 0 ]
+# [ 1 1 0 0 0 1 ]
+# [ 1 0 0 0 0 0 ]
+#
+# Output: [ 0 0 0 ]
+# [ 0 0 0 ]
+# Example 2:
+# Input : [ 0 0 1 1 ]
+# [ 0 0 0 1 ]
+# [ 0 0 1 0 ]
+#
+# Output: [ 0 0 ]
+# [ 0 0 ]
+# [ 0 0 ]
+
+# method:
+#
+# kind of hard for a first task, I'd say. I mean, not actualy hard per se, but it
+# took me a while to twig to the idea of comparing the row elements using a
+# logical OR to encode searches over multiple rows. It's kind of abstract. Perhaps
+# this is a well-known problem or something, but I have no intention of checking
+# or doing any more research at all.
+#
+# Let's have at it.
+#
+# Searching a single row for a (figurative) string of 0s is not a complex task in itself.
+# The trouble starts when you start to look at sub-matrices covering several rows.
+#
+# We could iterate through the matrix and check each position as potentially the upper-left
+# corner of a submatrix: we could look to the right for a contiuation of 0s and then down
+# to figure out the other dimension at every new zero found. A little bookkeeping records the
+# row and column counts, to be reproduced for output.
+#
+# I suppose that's the easy way, but it sounds like a *lot* of nested loops to me.
+#
+# Alternatly we could do all of the searching of a given multidimension at once in a
+# list-wise process, using a bitwise OR, and assemble summed lists for every continuous group
+# of rows.
+#
+# Say, for a 3x3 matrix, we'll have lists for rows
+#
+# (1)
+# (1,2)
+# (1,2,3)
+# (2)
+# (2,3) and
+# (3)
+#
+# If that pattern looks a bit familiar it's the trianglular numbers, right? Well the number
+# of combinations total to the triangular numbers: (1,3,6,10,15,21), or n*(n+1)/2 .
+
+
+#
+# © 2021 colin crain
+## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
+
+
+
+use warnings;
+use strict;
+use utf8;
+use feature ":5.26";
+use feature qw(signatures);
+no warnings 'experimental::signatures';
+
+
+my @input = ( [ 1, 0, 0, 0, 1, 0, ],
+ [ 1, 1, 0, 0, 0, 1, ],
+ [ 1, 1, 0, 0, 0, 1, ],
+ [ 1, 1, 0, 0, 0, 1, ],
+ [ 1, 0, 0, 0, 0, 0, ]
+);
+
+my @largest = ( 0, [] );
+
+for my $start_row ( 0..$#input ) {
+ my @composite_row = $input[$start_row]->@*;
+ for my $end_row ($start_row..$#input) {
+ my $span = $end_row - $start_row + 1;
+ $end_row > $start_row and @composite_row = listwise_OR( \@composite_row, $input[$end_row]) ;
+ my $zeros = max_zeros( @composite_row ) ;
+ my $sub_zeros = $zeros * $span;
+ if ( $sub_zeros > $largest[0] ) {
+ @largest = ( $sub_zeros, [$span, $zeros]);
+ }
+ }
+}
+
+print_output_mat( $largest[1] );
+
+
+
+sub listwise_OR ($arr1, $arr2) {
+ my @out;
+ for (0..$arr1->$#*) {
+ push @out, $arr1->[$_] | $arr2->[$_] ;
+ }
+ return @out;
+}
+
+sub max_zeros ( @arr ) {
+ my $zeros = 0;
+ my $count = 0;
+ for (0..$#arr) {
+ if ($arr[$_] == 1) {
+ $zeros = $count if $zeros < $count;
+ $count = 0;
+ next;
+ }
+ $count++;
+ }
+ return $zeros;
+}
+
+sub print_output_mat ( $dim ) {
+ say "[ " . (join ' ', (0) x $dim->[1]) . " ]" for (0..$dim->[0]-1);
+
+}
diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 0bea8dd774..7cb48980fc 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,130 +1,14 @@ { - "title" : { - "text" : "The Weekly Challenge - 128" - }, - "series" : [ - { - "name" : "The Weekly Challenge - 128", - "data" : [ - { - "name" : "Abigail", - "y" : 4, - "drilldown" : "Abigail" - }, - { - "name" : "Adam Russell", - "y" : 3, - "drilldown" : "Adam Russell" - }, - { - "drilldown" : "Arne Sommer", - "y" : 3, - "name" : "Arne Sommer" - }, - { - "name" : "Bruce Gray", - "y" : 4, - "drilldown" : "Bruce Gray" - }, - { - "name" : "Cheok-Yin Fung", - "y" : 3, - "drilldown" : "Cheok-Yin Fung" - }, - { - "drilldown" : "Dave Jacoby", - "name" : "Dave Jacoby", - "y" : 3 - }, - { - "name" : "Duncan C. White", - "y" : 2, - "drilldown" : "Duncan C. White" - }, - { - "drilldown" : "E. Choroba", - "y" : 2, - "name" : "E. Choroba" - }, - { - "drilldown" : "Flavio Poletti", - "name" : "Flavio Poletti", - "y" : 6 - }, - { - "y" : 3, - "name" : "James Smith", - "drilldown" : "James Smith" - }, - { - "name" : "Jan Krnavek", - "y" : 1, - "drilldown" : "Jan Krnavek" - }, - { - "name" : "Jorg Sommrey", - "y" : 2, - "drilldown" : "Jorg Sommrey" - }, - { - "name" : "Luca Ferrari", - "y" : 4, - "drilldown" : "Luca Ferrari" - }, - { - "name" : "Mark Anderson", - "y" : 2, - "drilldown" : "Mark Anderson" - }, - { - "drilldown" : "Matthew Neleigh", - "y" : 2, - "name" : "Matthew Neleigh" - }, - { - "drilldown" : "Peter Campbell Smith", - "name" : "Peter Campbell Smith", - "y" : 1 - }, - { - "y" : 5, - "name" : "Roger Bell_West", - "drilldown" : "Roger Bell_West" - }, - { - "name" : "Simon Green", - "y" : 3, - "drilldown" : "Simon Green" - }, - { - "drilldown" : "Stuart Little", - "name" : "Stuart Little", - "y" : 4 - }, - { - "name" : "Ulrich Rieke", - "y" : 2, - "drilldown" : "Ulrich Rieke" - }, - { - "drilldown" : "W. Luis Mochan", - "y" : 3, - "name" : "W. Luis Mochan" - }, - { - "name" : "Wanderdoc", - "y" : 1, - "drilldown" : "Wanderdoc" - } - ], - "colorByPoint" : 1 + "yAxis" : { + "title" : { + "text" : "Total Solutions" } - ], + }, "drilldown" : { "series" : [ { - "id" : "Abigail", "name" : "Abigail", + "id" : "Abigail", "data" : [ [ "Perl", @@ -137,6 +21,7 @@ ] }, { + "name" : "Adam Russell", "data" : [ [ "Perl", @@ -147,12 +32,10 @@ 1 ] ], - "id" : "Adam Russell", - "name" : "Adam Russell" + "id" : "Adam Russell" }, { "id" : "Arne Sommer", - "name" : "Arne Sommer", "data" : [ [ "Raku", @@ -162,11 +45,10 @@ "Blog", 1 ] - ] + ], + "name" : "Arne Sommer" }, { - "id" : "Bruce Gray", - "name" : "Bruce Gray", "data" : [ [ "Perl", @@ -176,11 +58,11 @@ "Raku", 2 ] - ] + ], + "id" : "Bruce Gray", + "name" : "Bruce Gray" }, { - "name" : "Cheok-Yin Fung", - "id" : "Cheok-Yin Fung", "data" : [ [ "Perl", @@ -190,10 +72,21 @@ "Blog", 1 ] - ] + ], + "id" : "Cheok-Yin Fung", + "name" : "Cheok-Yin Fung" + }, + { + "id" : "Colin Crain", + "data" : [ + [ + "Perl", + 1 + ] + ], + "name" : "Colin Crain" }, { - "id" : "Dave Jacoby", "name" : "Dave Jacoby", "data" : [ [ @@ -204,30 +97,30 @@ "Blog", 1 ] - ] + ], + "id" : "Dave Jacoby" }, { + "name" : "Duncan C. White", "data" : [ [ "Perl", 2 ] ], - "name" : "Duncan C. White", "id" : "Duncan C. White" }, { - "name" : "E. Choroba", - "id" : "E. Choroba", "data" : [ [ "Perl", 2 ] - ] + ], + "id" : "E. Choroba", + "name" : "E. Choroba" }, { - "id" : "Flavio Poletti", "name" : "Flavio Poletti", "data" : [ [ @@ -242,11 +135,12 @@ "Blog", 2 ] - ] + ], + "id" : "Flavio Poletti" }, { - "id" : "James Smith", "name" : "James Smith", + "id" : "James Smith", "data" : [ [ "Perl", @@ -259,13 +153,13 @@ ] }, { + "id" : "Jan Krnavek", "data" : [ [ "Raku", 1 ] ], - "id" : "Jan Krnavek", "name" : "Jan Krnavek" }, { @@ -275,10 +169,11 @@ 2 ] ], - "name" : "Jorg Sommrey", - "id" : "Jorg Sommrey" + "id" : "Jorg Sommrey", + "name" : "Jorg Sommrey" }, { + "id" : "Luca Ferrari", "data" : [ [ "Raku", @@ -289,28 +184,27 @@ 2 ] ], - "id" : "Luca Ferrari", "name" : "Luca Ferrari" }, { - "id" : "Mark Anderson", "name" : "Mark Anderson", "data" : [ [ "Raku", 2 ] - ] + ], + "id" : "Mark Anderson" }, { "name" : "Matthew Neleigh", - "id" : "Matthew Neleigh", "data" : [ [ "Perl", 2 ] - ] + ], + "id" : "Matthew Neleigh" }, { "data" : [ @@ -323,8 +217,6 @@ "name" : "Peter Campbell Smith" }, { - "name" : "Roger Bell_West", - "id" : "Roger Bell_West", "data" : [ [ "Perl", @@ -338,10 +230,11 @@ "Blog", 1 ] - ] + ], + "id" : "Roger Bell_West", + "name" : "Roger Bell_West" }, { - "name" : "Simon Green", "id" : "Simon Green", "data" : [ [ @@ -352,9 +245,11 @@ "Blog", 1 ] - ] + ], + "name" : "Simon Green" }, { + "id" : "Stuart Little", "data" : [ [ "Perl", @@ -365,12 +260,9 @@ 2 ] ], - "id" : "Stuart Little", "name" : "Stuart Little" }, { - "id" : "Ulrich Rieke", - "name" : "Ulrich Rieke", "data" : [ [ "Perl", @@ -380,7 +272,9 @@ "Raku", 1 ] - ] + ], + "id" : "Ulrich Rieke", + "name" : "Ulrich Rieke" }, { "name" : "W. Luis Mochan", @@ -398,29 +292,23 @@ }, { "id" : "Wanderdoc", - "name" : "Wanderdoc", "data" : [ [ "Perl", 1 ] - ] + ], + "name" : "Wanderdoc" } ] }, - "legend" : { - "enabled" : 0 - }, "xAxis" : { "type" : "category" }, - "chart" : { - "type" : "column" - }, "tooltip" : { - "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", + "followPointer" : 1, "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", - "followPointer" : 1 + "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>" }, "plotOptions" : { "series" : { @@ -431,12 +319,139 @@ "borderWidth" : 0 } }, - "subtitle" : { - "text" : "[Champions: 22] Last updated at 2021-09-05 23:00:51 GMT" + "chart" : { + "type" : "column" }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" + "legend" : { + "enabled" : 0 + }, + "series" : [ + { + "data" : [ + { + "name" : "Abigail", + "drilldown" : "Abigail", + "y" : 4 + }, + { + "y" : 3, + "name" : "Adam Russell", + "drilldown" : "Adam Russell" + }, + { + "name" : "Arne Sommer", + "drilldown" : "Arne Sommer", + "y" : 3 + }, + { + "name" : "Bruce Gray", + "drilldown" : "Bruce Gray", + "y" : 4 + }, + { + "y" : 3, + "drilldown" : "Cheok-Yin Fung", + "name" : "Cheok-Yin Fung" + }, + { + "drilldown" : "Colin Crain", + "name" : "Colin Crain", + "y" : 1 + }, + { + "name" : "Dave Jacoby", + "drilldown" : "Dave Jacoby", + "y" : 3 + }, + { + "name" : "Duncan C. White", + "drilldown" : "Duncan C. White", + "y" : 2 + }, + { + "y" : 2, + "drilldown" : "E. Choroba", + "name" : "E. Choroba" + }, + { + "y" : 6, + "drilldown" : "Flavio Poletti", + "name" : "Flavio Poletti" + }, + { + "y" : 3, + "name" : "James Smith", + "drilldown" : "James Smith" + }, + { + "y" : 1, + "name" : "Jan Krnavek", + "drilldown" : "Jan Krnavek" + }, + { + "name" : "Jorg Sommrey", + "drilldown" : "Jorg Sommrey", + "y" : 2 + }, + { + "y" : 4, + "drilldown" : "Luca Ferrari", + "name" : "Luca Ferrari" + }, + { + "y" : 2, + "name" : "Mark Anderson", + "drilldown" : "Mark Anderson" + }, + { + "name" : "Matthew Neleigh", + "drilldown" : "Matthew Neleigh", + "y" : 2 + }, + { + "drilldown" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith", + "y" : 1 + }, + { + "y" : 5, + "drilldown" : "Roger Bell_West", + "name" : "Roger Bell_West" + }, + { + "name" : "Simon Green", + "drilldown" : "Simon Green", + "y" : 3 + }, + { + "drilldown" : "Stuart Little", + "name" : "Stuart Little", + "y" : 4 + }, + { + "y" : 2, + "drilldown" : "Ulrich Rieke", + "name" : "Ulrich Rieke" + }, + { + "y" : 3, + "name" : "W. Luis Mochan", + "drilldown" : "W. Luis Mochan" + }, + { + "y" : 1, + "name" : "Wanderdoc", + "drilldown" : "Wanderdoc" + } + ], + "colorByPoint" : 1, + "name" : "The Weekly Challenge - 128" } + ], + "title" : { + "text" : "The Weekly Challenge - 128" + }, + "subtitle" : { + "text" : "[Champions: 23] Last updated at 2021-09-06 02:23:17 GMT" } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 4aed286ef7..b34e201165 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -2,9 +2,27 @@ "title" : { "text" : "The Weekly Challenge Contributions [2019 - 2021]" }, + "subtitle" : { + "text" : "Last updated at 2021-09-06 02:23:17 GMT" + }, "tooltip" : { "pointFormat" : "<b>{point.y:.0f}</b>" }, + "xAxis" : { + "type" : "category", + "labels" : { + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + } + } + }, + "chart" : { + "type" : "column" + }, + "legend" : { + "enabled" : "false" + }, "series" : [ { "data" : [ @@ -14,50 +32,32 @@ ], [ "Perl", - 6144 + 6145 ], [ "Raku", 3793 ] ], + "name" : "Contributions", "dataLabels" : { - "enabled" : "true", + "align" : "right", "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" }, - "align" : "right", + "rotation" : -90, + "enabled" : "true", "color" : "#FFFFFF", "y" : 10, - "rotation" : -90, "format" : "{point.y:.0f}" - }, - "name" : "Contributions" + } } ], - "subtitle" : { - "text" : "Last updated at 2021-09-05 23:00:51 GMT" - }, - "legend" : { - "enabled" : "false" - }, "yAxis" : { "min" : 0, "title" : { "text" : null } - }, - "xAxis" : { - "type" : "category", - "labels" : { - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - } - } - }, - "chart" : { - "type" : "column" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 82b56d158d..e432a8535d 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,6 +1,17 @@ { - "legend" : { - "enabled" : "false" + "tooltip" : { + "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>", + "headerFormat" : "<span style=\"font-size:11px\"></span>", + "followPointer" : "true" + }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } }, "chart" : { "type" : "column" @@ -8,19 +19,21 @@ "xAxis" : { "type" : "category" }, + "legend" : { + "enabled" : "false" + }, "series" : [ { - "colorByPoint" : "true", "data" : [ { "drilldown" : "001", - "y" : 161, - "name" : "#001" + "name" : "#001", + "y" : 161 }, { - "y" : 125, "name" : "#002", - "drilldown" : "002" + "drilldown" : "002", + "y" : 125 }, { "drilldown" : "003", @@ -28,48 +41,48 @@ "y" : 81 }, { - "drilldown" : "004", "y" : 99, - "name" : "#004" + "name" : "#004", + "drilldown" : "004" }, { - "drilldown" : "005", "y" : 78, - "name" : "#005" + "name" : "#005", + "drilldown" : "005" }, { "name" : "#006", - "y" : 58, - "drilldown" : "006" + "drilldown" : "006", + "y" : 58 }, { - "drilldown" : "007", "y" : 64, - "name" : "#007" + "name" : "#007", + "drilldown" : "007" }, { - "drilldown" : "008", + "y" : 78, "name" : "#008", - "y" : 78 + "drilldown" : "008" }, { + "name" : "#009", "drilldown" : "009", - "y" : 76, - "name" : "#009" + "y" : 76 }, { "drilldown" : "010", - "y" : 65, - "name" : "#010" + "name" : "#010", + "y" : 65 }, { - "y" : 85, "name" : "#011", - "drilldown" : "011" + "drilldown" : "011", + "y" : 85 }, { - "drilldown" : "012", "y" : 89, + "drilldown" : "012", "name" : "#012" }, { @@ -79,47 +92,47 @@ }, { "name" : "#014", - "y" : 101, - "drilldown" : "014" + "drilldown" : "014", + "y" : 101 }, { + "name" : "#015", "drilldown" : "015", - "y" : 99, - "name" : "#015" + "y" : 99 }, { - "y" : 71, "name" : "#016", - "drilldown" : "016" + "drilldown" : "016", + "y" : 71 }, { + "y" : 84, "drilldown" : "017", - "name" : "#017", - "y" : 84 + "name" : "#017" }, { - "drilldown" : "018", + "y" : 81, "name" : "#018", - "y" : 81 + "drilldown" : "018" }, { - "drilldown" : "019", "name" : "#019", + "drilldown" : "019", "y" : 103 }, { "y" : 101, - "name" : "#020", - "drilldown" : "020" + "drilldown" : "020", + "name" : "#020" }, { "drilldown" : "021", - "y" : 72, - "name" : "#021" + "name" : "#021", + "y" : 72 }, { - "name" : "#022", "y" : 68, + "name" : "#022", "drilldown" : "022" }, { @@ -128,9 +141,9 @@ "drilldown" : "023" }, { + "name" : "#024", "drilldown" : "024", - "y" : 75, - "name" : "#024" + "y" : 75 }, { "y" : 59, @@ -138,44 +151,44 @@ "drilldown" : "025" }, { - "drilldown" : "026", "y" : 74, + "drilldown" : "026", "name" : "#026" }, { - "y" : 60, "name" : "#027", - "drilldown" : "027" + "drilldown" : "027", + "y" : 60 }, { "drilldown" : "028", - "y" : 80, - "name" : "#028" + "name" : "#028", + "y" : 80 }, { + "drilldown" : "029", "name" : "#029", - "y" : 79, - "drilldown" : "029" + "y" : 79 }, { - "drilldown" : "030", "y" : 117, + "drilldown" : "030", "name" : "#030" }, { "drilldown" : "031", - "y" : 89, - "name" : "#031" + "name" : "#031", + "y" : 89 }, { "drilldown" : "032", - "y" : 94, - "name" : "#032" + "name" : "#032", + "y" : 94 }, { "drilldown" : "033", - "y" : 110, - "name" : "#033" + "name" : "#033", + "y" : 110 }, { "drilldown" : "034", @@ -183,13 +196,13 @@ "y" : 64 }, { - "drilldown" : "035", "y" : 64, + "drilldown" : "035", "name" : "#035" }, { - "drilldown" : "036", "y" : 68, + "drilldown" : "036", "name" : "#036" }, { @@ -198,64 +211,64 @@ "y" : 67 }, { - "drilldown" : "038", "name" : "#038", + "drilldown" : "038", "y" : 68 }, < |
