diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-05-28 11:17:31 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-05-28 11:17:31 +0100 |
| commit | 784491507d451cfb9261c15082cec5e0e48640ae (patch) | |
| tree | 0a87ac6e8b454a1847169149da85d5d1890b6d68 | |
| parent | e7b136458d77cbaf689c60de4d20c6eb2ad0d680 (diff) | |
| download | perlweeklychallenge-club-784491507d451cfb9261c15082cec5e0e48640ae.tar.gz perlweeklychallenge-club-784491507d451cfb9261c15082cec5e0e48640ae.tar.bz2 perlweeklychallenge-club-784491507d451cfb9261c15082cec5e0e48640ae.zip | |
- Added solutions by Luca Ferrari.
- Added solutions by E. Choroba.
- Added solutions by Jorg Sommrey.
- Added solutions by Steven Wilson.
- Added solutions by Peter Meszaros.
- Added solutions by Thomas Kohler.
- Added solutions by Peter Campbell Smith.
- Added solutions by Ali Moradi.
- Added solutions by Packy Anderson.
- Added solutions by Roger Bell_West.
- Added solutions by Reinier Maliepaard.
| -rw-r--r-- | challenge-271/reinier-maliepaard/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-271/reinier-maliepaard/perl/ch-1.pl | 89 | ||||
| -rw-r--r-- | challenge-271/reinier-maliepaard/perl/ch-2.pl | 29 | ||||
| -rw-r--r-- | stats/pwc-challenge-270.json | 456 | ||||
| -rw-r--r-- | stats/pwc-current.json | 264 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 58 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 3758 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 484 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 106 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 108 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 58 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 110 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 42 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 48 | ||||
| -rw-r--r-- | stats/pwc-summary-271-300.json | 42 | ||||
| -rw-r--r-- | stats/pwc-summary-301-330.json | 32 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 50 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 48 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 108 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 80 |
20 files changed, 3123 insertions, 2848 deletions
diff --git a/challenge-271/reinier-maliepaard/blog.txt b/challenge-271/reinier-maliepaard/blog.txt new file mode 100644 index 0000000000..0dc037d66c --- /dev/null +++ b/challenge-271/reinier-maliepaard/blog.txt @@ -0,0 +1 @@ +https://reiniermaliepaard.nl/perl/pwc/index.php?id=pwc271 diff --git a/challenge-271/reinier-maliepaard/perl/ch-1.pl b/challenge-271/reinier-maliepaard/perl/ch-1.pl new file mode 100644 index 0000000000..b960eb32b3 --- /dev/null +++ b/challenge-271/reinier-maliepaard/perl/ch-1.pl @@ -0,0 +1,89 @@ +#!/usr/bin/perl +use strict; +use warnings; +use Math::Matrix; + +sub row_max_ones { + + my ($x) = @_; + # a boolean matrix is a matrix whose entries are either 0 or 1 + if ( $x -> is_bool() ) { + + # find() returns the location of each non-zero element in terms of $i and $j. + # e.g. (0, 0), (0, 2), (1, 0) and (2, 0) are the coordinates of value 1 in Example 4 below + my($i, $j) = $x -> find(); + + # count occurrences of each element and save into %count + my %count; + + foreach my $elem (@$i) { + $count{$elem}++; + } + + # alternatively: map { $count{$_}++ } @$i; + + # iterate through the hash to find the maximum value + my ($max_value, $max_row) = (0, 0); + + foreach my $row (sort keys(%count)) { + + if ($count{$row} > $max_value) { + $max_value = $count{$row}; + # assign $row to $max_row only if both $max_value and $row have become new values + $max_row = $row if ($max_value != 0 && $row != $max_row); + } + } + + print("Row maximum ones: ", ($max_row + 1), "\n"); + + } + else { + print("Error: no valid matrix!\n"); + } +} + +# TESTS +my $matrix; + +# Example 1 +$matrix = [ [0, 1], + [1, 0], + ]; +row_max_ones(Math::Matrix -> new($matrix)); # Output: 1 + +# Example 2 +$matrix = [ [0, 0, 0], + [1, 0, 1], + ]; +row_max_ones(Math::Matrix -> new($matrix)); # Output: 2 + +# Example 3 +$matrix = [ [0, 0], + [1, 1], + [0, 0], + ]; +row_max_ones(Math::Matrix -> new($matrix)); # Output: 2 + +# own test cases +my $x; + +# Example 4 +$x = Math::Matrix -> new([1, 0, 1], + [1, 0, 0], + [1, 0, 0]); + +row_max_ones($x); # Output: 1 + +# Example 5 +$x = Math::Matrix -> new([1, 0, 0], + [1, 0, 0], + [1, 0, 1]); + +row_max_ones($x); # Output: 3 + +# Example 6 +$x = Math::Matrix -> new([1, 0, 0], + [1, 0, 1], + [1, 0, 1]); + +row_max_ones($x); # Output: 2 diff --git a/challenge-271/reinier-maliepaard/perl/ch-2.pl b/challenge-271/reinier-maliepaard/perl/ch-2.pl new file mode 100644 index 0000000000..0e8680010d --- /dev/null +++ b/challenge-271/reinier-maliepaard/perl/ch-2.pl @@ -0,0 +1,29 @@ +#!/usr/bin/perl +use strict; +use warnings; + +# function to count the number of 1 bits in the binary representation +sub count_ones { + return(my $count = sprintf("%b", @_) =~ tr/1//); +} + +sub count_sort_1_bits { + my @numbers = @_; + + # count the number of 1 bits for each number and save to %hash + my %hash; + foreach my $number (@numbers) { + my $ones_count = count_ones($number); + $hash{$number} = $ones_count; + } + + # sort keys by their values in ascending order + my @sorted_keys_asc = sort { $hash{$a} <=> $hash{$b} } sort(keys %hash); + + # join for the right output + print("(", join(", ", @sorted_keys_asc), ")\n"); +} + +# TESTS +my @numbers = (0, 1, 2, 3, 4, 5, 6, 7, 8); +count_sort_1_bits(@numbers); # Output: (0, 1, 2, 4, 8, 3, 5, 6, 7) diff --git a/stats/pwc-challenge-270.json b/stats/pwc-challenge-270.json index 1ab6e4b33b..7e3b62cf44 100644 --- a/stats/pwc-challenge-270.json +++ b/stats/pwc-challenge-270.json @@ -1,24 +1,197 @@ { - "subtitle" : { - "text" : "[Champions: 30] Last updated at 2024-05-27 11:19:38 GMT" + "series" : [ + { + "data" : [ + { + "y" : 3, + "drilldown" : "Arne Sommer", + "name" : "Arne Sommer" + }, + { + "y" : 4, + "drilldown" : "Athanasius", + "name" : "Athanasius" + }, + { + "y" : 1, + "name" : "BarrOff", + "drilldown" : "BarrOff" + }, + { + "y" : 2, + "name" : "Bob Lied", + "drilldown" : "Bob Lied" + }, + { + "y" : 2, + "drilldown" : "Bruce Gray", + "name" : "Bruce Gray" + }, + { + "drilldown" : "Dave Jacoby", + "name" : "Dave Jacoby", + "y" : 3 + }, + { + "name" : "David Ferrone", + "drilldown" : "David Ferrone", + "y" : 1 + }, + { + "drilldown" : "E. Choroba", + "name" : "E. Choroba", + "y" : 2 + }, + { + "name" : "Feng Chang", + "drilldown" : "Feng Chang", + "y" : 2 + }, + { + "y" : 1, + "drilldown" : "Jan Krnavek", + "name" : "Jan Krnavek" + }, + { + "y" : 4, + "name" : "Jorg Sommrey", + "drilldown" : "Jorg Sommrey" + }, + { + "y" : 1, + "drilldown" : "Lance Wicks", + "name" : "Lance Wicks" + }, + { + "drilldown" : "Laurent Rosenfeld", + "name" : "Laurent Rosenfeld", + "y" : 3 + }, + { + "y" : 11, + "drilldown" : "Luca Ferrari", + "name" : "Luca Ferrari" + }, + { + "drilldown" : "Mark Anderson", + "name" : "Mark Anderson", + "y" : 1 + }, + { + "y" : 1, + "drilldown" : "Matthew Neleigh", + "name" : "Matthew Neleigh" + }, + { + "y" : 3, + "drilldown" : "Matthias Muth", + "name" : "Matthias Muth" + }, + { + "y" : 2, + "drilldown" : "Nelo Tovar", + "name" : "Nelo Tovar" + }, + { + "y" : 2, + "name" : "Niels van Dijke", + "drilldown" : "Niels van Dijke" + }, + { + "name" : "Packy Anderson", + "drilldown" : "Packy Anderson", + "y" : 5 + }, + { + "y" : 3, + "name" : "Peter Campbell Smith", + "drilldown" : "Peter Campbell Smith" + }, + { + "drilldown" : "Peter Meszaros", + "name" : "Peter Meszaros", + "y" : 2 + }, + { + "drilldown" : "Reinier Maliepaard", + "name" : "Reinier Maliepaard", + "y" : 4 + }, + { + "y" : 2, + "name" : "Robbie Hatley", + "drilldown" : "Robbie Hatley" + }, + { + "drilldown" : "Robert Ransbottom", + "name" : "Robert Ransbottom", + "y" : 2 + }, + { + "y" : 5, + "drilldown" : "Roger Bell_West", + "name" : "Roger Bell_West" + }, + { + "y" : 3, + "name" : "Simon Green", + "drilldown" : "Simon Green" + }, + { + "y" : 4, + "name" : "Thomas Kohler", + "drilldown" : "Thomas Kohler" + }, + { + "drilldown" : "Ulrich Rieke", + "name" : "Ulrich Rieke", + "y" : 4 + }, + { + "drilldown" : "W. Luis Mochan", + "name" : "W. Luis Mochan", + "y" : 3 + } + ], + "colorByPoint" : 1, + "name" : "The Weekly Challenge - 270" + } + ], + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } }, - "legend" : { - "enabled" : 0 + "chart" : { + "type" : "column" }, "xAxis" : { "type" : "category" }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, "tooltip" : { - "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/>", - "followPointer" : 1 + "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>" }, - "chart" : { - "type" : "column" + "legend" : { + "enabled" : 0 + }, + "title" : { + "text" : "The Weekly Challenge - 270" }, "drilldown" : { "series" : [ { + "id" : "Arne Sommer", "data" : [ [ "Raku", @@ -29,12 +202,11 @@ 1 ] ], - "name" : "Arne Sommer", - "id" : "Arne Sommer" + "name" : "Arne Sommer" }, { - "id" : "Athanasius", "name" : "Athanasius", + "id" : "Athanasius", "data" : [ [ "Perl", @@ -58,17 +230,17 @@ }, { "id" : "Bob Lied", - "name" : "Bob Lied", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Bob Lied" }, { - "id" : "Bruce Gray", "name" : "Bruce Gray", + "id" : "Bruce Gray", "data" : [ [ "Raku", @@ -77,7 +249,6 @@ ] }, { - "id" : "Dave Jacoby", "data" : [ [ "Perl", @@ -88,11 +259,12 @@ 1 ] ], + "id" : "Dave Jacoby", "name" : "Dave Jacoby" }, { - "id" : "David Ferrone", "name" : "David Ferrone", + "id" : "David Ferrone", "data" : [ [ "Perl", @@ -101,37 +273,37 @@ ] }, { - "name" : "E. Choroba", "data" : [ [ "Perl", 2 ] ], - "id" : "E. Choroba" + "id" : "E. Choroba", + "name" : "E. Choroba" }, { - "id" : "Feng Chang", "name" : "Feng Chang", "data" : [ [ "Raku", 2 ] - ] + ], + "id" : "Feng Chang" }, { "id" : "Jan Krnavek", - "name" : "Jan Krnavek", "data" : [ [ "Raku", 1 ] - ] + ], + "name" : "Jan Krnavek" }, { - "name" : "Jorg Sommrey", + "id" : "Jorg Sommrey", "data" : [ [ "Perl", @@ -139,24 +311,23 @@ ], [ "Blog", - 1 + 2 ] ], - "id" : "Jorg Sommrey" + "name" : "Jorg Sommrey" }, { - "name" : "Lance Wicks", "data" : [ [ "Perl", 1 ] ], - "id" : "Lance Wicks" + "id" : "Lance Wicks", + "name" : "Lance Wicks" }, { "id" : "Laurent Rosenfeld", - "name" : "Laurent Rosenfeld", "data" : [ [ "Perl", @@ -170,10 +341,11 @@ "Blog", 1 ] - ] + ], + "name" : "Laurent Rosenfeld" }, { - "name" : "Luca Ferrari", + "id" : "Luca Ferrari", "data" : [ [ "Raku", @@ -184,11 +356,11 @@ 9 ] ], - "id" : "Luca Ferrari" + "name" : "Luca Ferrari" }, { - "id" : "Mark Anderson", "name" : "Mark Anderson", + "id" : "Mark Anderson", "data" : [ [ "Raku", @@ -197,13 +369,13 @@ ] }, { + "name" : "Matthew Neleigh", "data" : [ [ "Perl", 1 ] ], - "name" : "Matthew Neleigh", "id" : "Matthew Neleigh" }, { @@ -217,8 +389,8 @@ 1 ] ], - "name" : "Matthias Muth", - "id" : "Matthias Muth" + "id" : "Matthias Muth", + "name" : "Matthias Muth" }, { "id" : "Nelo Tovar", @@ -237,12 +409,12 @@ 2 ] ], - "name" : "Niels van Dijke", - "id" : "Niels van Dijke" + "id" : "Niels van Dijke", + "name" : "Niels van Dijke" }, { - "id" : "Packy Anderson", "name" : "Packy Anderson", + "id" : "Packy Anderson", "data" : [ [ "Perl", @@ -259,8 +431,8 @@ ] }, { - "id" : "Peter Campbell Smith", "name" : "Peter Campbell Smith", + "id" : "Peter Campbell Smith", "data" : [ [ "Perl", @@ -274,15 +446,16 @@ }, { "name" : "Peter Meszaros", + "id" : "Peter Meszaros", "data" : [ [ "Perl", 2 ] - ], - "id" : "Peter Meszaros" + ] }, { + "name" : "Reinier Maliepaard", "id" : "Reinier Maliepaard", "data" : [ [ @@ -293,8 +466,7 @@ "Blog", 2 ] - ], - "name" : "Reinier Maliepaard" + ] }, { "name" : "Robbie Hatley", @@ -311,16 +483,18 @@ "id" : "Robbie Hatley" }, { + "name" : "Robert Ransbottom", "id" : "Robert Ransbottom", "data" : [ [ "Raku", 2 ] - ], - "name" : "Robert Ransbottom" + ] }, { + "name" : "Roger Bell_West", + "id" : "Roger Bell_West", "data" : [ [ "Perl", @@ -334,9 +508,7 @@ "Blog", 1 ] - ], - "name" : "Roger Bell_West", - "id" : "Roger Bell_West" + ] }, { "name" : "Simon Green", @@ -368,6 +540,7 @@ }, { "name" : "Ulrich Rieke", + "id" : "Ulrich Rieke", "data" : [ [ "Perl", @@ -377,10 +550,11 @@ "Raku", 2 ] - ], - "id" : "Ulrich Rieke" + ] }, { + "name" : "W. Luis Mochan", + "id" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -390,185 +564,11 @@ "Blog", 1 ] - ], - "name" : "W. Luis Mochan", - "id" : "W. Luis Mochan" + ] } ] }, - "title" : { - "text" : "The Weekly Challenge - 270" - }, - "plotOptions" : { - "series" : { - "borderWidth" : 0, - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - } - } - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "series" : [ - { - "colorByPoint" : 1, - "name" : "The Weekly Challenge - 270", - "data" : [ - { - "drilldown" : "Arne Sommer", - "y" : 3, - "name" : "Arne Sommer" - }, - { - "y" : 4, - "drilldown" : "Athanasius", - "name" : "Athanasius" - }, - { - "name" : "BarrOff", - "drilldown" : "BarrOff", - "y" : 1 - }, - { - "y" : 2, - "drilldown" : "Bob Lied", - "name" : "Bob Lied" - }, - { - "name" : "Bruce Gray", - "drilldown" : "Bruce Gray", - "y" : 2 - }, - { - "name" : "Dave Jacoby", - "drilldown" : "Dave Jacoby", - "y" : 3 - }, - { - "name" : "David Ferrone", - "drilldown" : "David Ferrone", - "y" : 1 - }, - { - "name" : "E. Choroba", - "y" : 2, - "drilldown" : "E. Choroba" - }, - { - "name" : "Feng Chang", - "y" : 2, - "drilldown" : "Feng Chang" - }, - { - "name" : "Jan Krnavek", - "y" : 1, - "drilldown" : "Jan Krnavek" - }, - { - "name" : "Jorg Sommrey", - "drilldown" : "Jorg Sommrey", - "y" : 3 - }, - { - "name" : "Lance Wicks", - "drilldown" : "Lance Wicks", - "y" : 1 - }, - { - "name" : "Laurent Rosenfeld", - "y" : 3, - "drilldown" : "Laurent Rosenfeld" - }, - { - "drilldown" : "Luca Ferrari", - "y" : 11, - "name" : "Luca Ferrari" - }, - { - "y" : 1, - "drilldown" : "Mark Anderson", - "name" : "Mark Anderson" - }, - { - "name" : "Matthew Neleigh", - "y" : 1, - "drilldown" : "Matthew Neleigh" - }, - { - "drilldown" : "Matthias Muth", - "y" : 3, - "name" : "Matthias Muth" - }, - { - "drilldown" : "Nelo Tovar", - "y" : 2, - "name" : "Nelo Tovar" - }, - { - "drilldown" : "Niels van Dijke", - "y" : 2, - "name" : "Niels van Dijke" - }, - { - "name" : "Packy Anderson", - "y" : 5, - "drilldown" : "Packy Anderson" - }, - { - "drilldown" : "Peter Campbell Smith", - "y" : 3, - "name" : "Peter Campbell Smith" - }, - { - "name" : "Peter Meszaros", - "y" : 2, - "drilldown" : "Peter Meszaros" - }, - { - "name" : "Reinier Maliepaard", - "y" : 4, - "drilldown" : "Reinier Maliepaard" - }, - { - "name" : "Robbie Hatley", - "y" : 2, - "drilldown" : "Robbie Hatley" - }, - { - "drilldown" : "Robert Ransbottom", - "y" : 2, - "name" : "Robert Ransbottom" - }, - { - "y" : 5, - "drilldown" : "Roger Bell_West", - "name" : "Roger Bell_West" - }, - { - "y" : 3, - "drilldown" : "Simon Green", - "name" : "Simon Green" - }, - { - "name" : "Thomas Kohler", - "drilldown" : "Thomas Kohler", - "y" : 4 - }, - { - "name" : "Ulrich Rieke", - "drilldown" : "Ulrich Rieke", - "y" : 4 - }, - { - "drilldown" : "W. Luis Mochan", - "y" : 3, - "name" : "W. Luis Mochan" - } - ] - } - ] + "subtitle" : { + "text" : "[Champions: 30] Last updated at 2024-05-28 09:52:57 GMT" + } } diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 242f5d4a03..0a79758f58 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,108 +1,264 @@ { - "tooltip" : { - "followPointer" : 1, - "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", - "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>" + "subtitle" : { + "text" : "[Champions: 12] Last updated at 2024-05-28 10:13:01 GMT" }, - "xAxis" : { - "type" : "category" + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } }, + "series" : [ + { + "name" : "The Weekly Challenge - 271", + "data" : [ + { + "drilldown" : "Ali Moradi", + "name" : "Ali Moradi", + "y" : 5 + }, + { + "drilldown" : "David Ferrone", + "y" : 2, + "name" : "David Ferrone" + }, + { + "name" : "Feng Chang", + "y" : 2, + "drilldown" : "Feng Chang" + }, + { + "name" : "Luca Ferrari", + "y" : 11, + "drilldown" : "Luca Ferrari" + }, + { + "name" : "Mark Anderson", + "y" : 2, + "drilldown" : "Mark Anderson" + }, + { + "y" : 2, + "name" : "Niels van Dijke", + "drilldown" : "Niels van Dijke" + }, + { + "drilldown" : "Packy Anderson", + "y" : 5, + "name" : "Packy Anderson" + }, + { + "drilldown" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith", + "y" : 3 + }, + { + "drilldown" : "Peter Meszaros", + "name" : "Peter Meszaros", + "y" : 2 + }, + { + "y" : 3, + "name" : "Reinier Maliepaard", + "drilldown" : "Reinier Maliepaard" + }, + { + "drilldown" : "Roger Bell_West", + "name" : "Roger Bell_West", + "y" : 4 + }, + { + "drilldown" : "Thomas Kohler", + "y" : 4, + "name" : "Thomas Kohler" + } + ], + "colorByPoint" : 1 + } + ], "title" : { "text" : "The Weekly Challenge - 271" }, + "tooltip" : { + "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/>" + }, "drilldown" : { "series" : [ { - "name" : "David Ferrone", + "name" : "Ali Moradi", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Ali Moradi" + }, + { "id" : "David Ferrone", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "David Ferrone" }, { "name" : "Feng Chang", - "id" : "Feng Chang", "data" : [ [ "Raku", 2 ] - ] + ], + "id" : "Feng Chang" + }, + { + "id" : "Luca Ferrari", + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 9 + ] + ], + "name" : "Luca Ferrari" }, { - "id" : "Mark Anderson", "name" : "Mark Anderson", "data" : [ [ "Raku", 2 ] - ] + ], + "id" : "Mark Anderson" }, { + "data" : [ + [ + "Perl", + 2 + ] + ], "id" : "Niels van Dijke", - "name" : "Niels van Dijke", + "name" : "Niels van Dijke" + }, + { + "name" : "Packy Anderson", + |
