diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-10-04 00:50:33 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-10-04 00:50:33 +0100 |
| commit | 31e6be25dc0305abdc5c24e6336d4b50fd1a8d51 (patch) | |
| tree | 8f8ae0a66b88cae69f7a7e4265ec7ffc57cd5671 | |
| parent | 6377ecda134f8e25d4f6bdedb0cf2b173c578d50 (diff) | |
| download | perlweeklychallenge-club-31e6be25dc0305abdc5c24e6336d4b50fd1a8d51.tar.gz perlweeklychallenge-club-31e6be25dc0305abdc5c24e6336d4b50fd1a8d51.tar.bz2 perlweeklychallenge-club-31e6be25dc0305abdc5c24e6336d4b50fd1a8d51.zip | |
- Added solutions by Pete Houston.
| -rwxr-xr-x | challenge-132/pete-houston/perl/ch-1.pl | 38 | ||||
| -rwxr-xr-x | challenge-132/pete-houston/perl/ch-2.pl | 76 | ||||
| -rw-r--r-- | stats/pwc-current.json | 427 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 66 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 898 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 744 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 110 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 118 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 118 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 54 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 46 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 42 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 42 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 46 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 36 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 48 |
16 files changed, 1519 insertions, 1390 deletions
diff --git a/challenge-132/pete-houston/perl/ch-1.pl b/challenge-132/pete-houston/perl/ch-1.pl new file mode 100755 index 0000000000..7479c28e88 --- /dev/null +++ b/challenge-132/pete-houston/perl/ch-1.pl @@ -0,0 +1,38 @@ +#!/usr/bin/env perl +#=============================================================================== +# +# FILE: 13201.pl +# +# USAGE: ./13201.pl YYYY/MM/DD [ REF_DATE ] +# +# DESCRIPTION: For the given date of birth, display the DoB of someone +# who would have been your age now on your birthday and +# the date at which someone born today would have your age +# now. +# +# OPTIONS: If REF_DATE is supplied use that as reference point +# instead of today. +# REQUIREMENTS: Time::Piece 1.31_01 (for truncate) +# AUTHOR: Pete Houston (pete), cpan@openstrike.co.uk +# ORGANIZATION: Openstrike +# VERSION: 1.0 +# CREATED: 27/09/21 +#=============================================================================== + +use strict; +use warnings; +use Time::Piece 1.31_01; + +my $dob = Time::Piece->strptime (shift, '%Y/%m/%d'); + +my $today = + scalar @ARGV ? + Time::Piece->strptime (shift, '%Y/%m/%d') : + localtime; + +my $diff = $today->truncate (to => 'day') - $dob; +die "Date supplied (" . $dob->ymd . ") is in the future.\n" if $diff < 0; + +my $past = $dob - $diff; +my $future = $today + $diff; +print $past->ymd ('/') . ' ' . $future->ymd ('/') . "\n"; diff --git a/challenge-132/pete-houston/perl/ch-2.pl b/challenge-132/pete-houston/perl/ch-2.pl new file mode 100755 index 0000000000..e2d74c7f61 --- /dev/null +++ b/challenge-132/pete-houston/perl/ch-2.pl @@ -0,0 +1,76 @@ +#!/usr/bin/env perl +#=============================================================================== +# +# FILE: 13202.pl +# +# USAGE: ./13202.pl MEMORY_LIMIT FILE1.csv FILE2.csv +# +# MEMORY_LIMIT is in bytes. Try 1024 or 512 for the +# provided input. +# FILE1.csv should be the ages, FILE2.csv the names. +# +# DESCRIPTION: Hash Join as per +# https://en.wikipedia.org/wiki/Hash_join#Classic_hash_join +# +# REQUIREMENTS: Devel::Size, Text::CSV, +# BUGS: Assumes input files are UTF-8 encoded. +# NOTES: The provided sample output's order is not replicated here +# AUTHOR: Pete Houston (pete), cpan@openstrike.co.uk +# ORGANIZATION: Openstrike +# VERSION: 1.0 +# CREATED: 02/10/21 +#=============================================================================== + +use strict; +use warnings; + +use Devel::Size 'total_size'; +use Text::CSV; + +binmode STDOUT, ":encoding(utf-8)"; +my $DEBUG = 1; # Switch to 0 for quiet mode + +# Store the full names +my $mem_limit = shift; +unless ($mem_limit =~ /^[0-9]+$/) { + warn "Supplied memory limit of $mem_limit is unusable.\n" . + "Setting to 1024 instead.\n"; + $mem_limit = 1024; +} +my $csv = Text::CSV->new ({binary => 1}); +open my $nfh, "<:encoding(utf8)", $ARGV[1] or die "Cannot open $ARGV[1]: $!"; +my @names; +while (my $name = $csv->getline ($nfh)) { + push @names, $name; +} +$csv->eof; +close $nfh; + +$csv = Text::CSV->new ({binary => 1}); +my $out = Text::CSV->new ({binary => 1}); + +# Build the hash of the ages +open my $afh, "<:encoding(utf8)", $ARGV[0] or die "Cannot open $ARGV[0]: $!"; +my %ages; +while (my $row = $csv->getline ($afh)) { + push @{$ages{$row->[1]}}, $row->[0]; + if (total_size (\%ages) >= $mem_limit) { + print "Limit hit!\n" if $DEBUG; + dump_out (\@names, \%ages, $out); + %ages = (); + } +} +close $afh; + +print "At end\n" if $DEBUG; +dump_out (\@names, \%ages, $out); + +sub dump_out { + my ($names, $ages, $csv) = @_; + for my $name (@$names) { + for my $age (@{$ages->{$name->[0]}}) { + $csv->combine ($age, @$name); + print $csv->string, "\n"; + } + } +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index fc42b62356..9d0ae74de8 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,163 +1,12 @@ { - "plotOptions" : { - "series" : { - "borderWidth" : 0, - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - } - } - }, - "series" : [ - { - "name" : "The Weekly Challenge - 132", - "data" : [ - { - "drilldown" : "Abigail", - "name" : "Abigail", - "y" : 4 - }, - { - "y" : 1, - "name" : "Adam Russell", - "drilldown" : "Adam Russell" - }, - { - "y" : 3, - "name" : "Arne Sommer", - "drilldown" : "Arne Sommer" - }, - { - "name" : "Athanasius", - "drilldown" : "Athanasius", - "y" : 2 - }, - { - "y" : 2, - "name" : "Ben Davies", - "drilldown" : "Ben Davies" - }, - { - "y" : 1, - "name" : "Cheok-Yin Fung", - "drilldown" : "Cheok-Yin Fung" - }, - { - "name" : "Dave Jacoby", - "drilldown" : "Dave Jacoby", - "y" : 3 - }, - { - "y" : 2, - "name" : "Duncan C. White", - "drilldown" : "Duncan C. White" - }, - { - "drilldown" : "E. Choroba", - "name" : "E. Choroba", - "y" : 2 - }, - { - "drilldown" : "Flavio Poletti", - "name" : "Flavio Poletti", - "y" : 6 - }, - { - "y" : 1, - "drilldown" : "James Raspass", - "name" : "James Raspass" - }, - { - "drilldown" : "James Smith", - "name" : "James Smith", - "y" : 3 - }, - { - "name" : "Jan Krnavek", - "drilldown" : "Jan Krnavek", - "y" : 1 - }, - { - "y" : 2, - "drilldown" : "Jorg Sommrey", - "name" : "Jorg Sommrey" - }, - { - "name" : "Laurent Rosenfeld", - "drilldown" : "Laurent Rosenfeld", - "y" : 5 - }, - { - "name" : "Lubos Kolouch", - "drilldown" : "Lubos Kolouch", - "y" : 1 - }, - { - "y" : 4, - "drilldown" : "Luca Ferrari", - "name" : "Luca Ferrari" - }, - { - "drilldown" : "Mark Anderson", - "name" : "Mark Anderson", - "y" : 2 - }, - { - "y" : 2, - "drilldown" : "Matthew Neleigh", - "name" : "Matthew Neleigh" - }, - { - "drilldown" : "Niels van Dijke", - "name" : "Niels van Dijke", - "y" : 2 - }, - { - "y" : 2, - "drilldown" : "Olivier Delouya", - "name" : "Olivier Delouya" - }, - { - "y" : 5, - "drilldown" : "Roger Bell_West", - "name" : "Roger Bell_West" - }, - { - "drilldown" : "Simon Proctor", - "name" : "Simon Proctor", - "y" : 1 - }, - { - "y" : 3, - "drilldown" : "Ulrich Rieke", - "name" : "Ulrich Rieke" - }, - { - "drilldown" : "W. Luis Mochan", - "name" : "W. Luis Mochan", - "y" : 3 - }, - { - "y" : 2, - "name" : "Wanderdoc", - "drilldown" : "Wanderdoc" - } - ], - "colorByPoint" : 1 - } - ], - "legend" : { - "enabled" : 0 - }, - "subtitle" : { - "text" : "[Champions: 26] Last updated at 2021-10-03 23:42:39 GMT" - }, - "title" : { - "text" : "The Weekly Challenge - 132" + "chart" : { + "type" : "column" }, "drilldown" : { "series" : [ { + "id" : "Abigail", + "name" : "Abigail", "data" : [ [ "Perl", @@ -167,9 +16,7 @@ "Blog", 2 ] - ], - "id" : "Abigail", - "name" : "Abigail" + ] }, { "id" : "Adam Russell", @@ -182,7 +29,6 @@ "name" : "Adam Russell" }, { - "name" : "Arne Sommer", "id" : "Arne Sommer", "data" : [ [ @@ -193,10 +39,10 @@ "Blog", 1 ] - ] + ], + "name" : "Arne Sommer" }, { - "id" : "Athanasius", "data" : [ [ "Perl", @@ -207,27 +53,28 @@ 1 ] ], - "name" : "Athanasius" + "name" : "Athanasius", + "id" : "Athanasius" }, { + "name" : "Ben Davies", "data" : [ [ "Raku", 2 ] ], - "id" : "Ben Davies", - "name" : "Ben Davies" + "id" : "Ben Davies" }, { + "id" : "Cheok-Yin Fung", + "name" : "Cheok-Yin Fung", "data" : [ [ "Perl", 1 ] - ], - "id" : "Cheok-Yin Fung", - "name" : "Cheok-Yin Fung" + ] }, { "id" : "Dave Jacoby", @@ -244,26 +91,27 @@ "name" : "Dave Jacoby" }, { - "name" : "Duncan C. White", "data" : [ [ "Perl", 2 ] ], + "name" : "Duncan C. White", "id" : "Duncan C. White" }, { - "name" : "E. Choroba", "data" : [ [ "Perl", 2 ] ], + "name" : "E. Choroba", "id" : "E. Choroba" }, { + "id" : "Flavio Poletti", "name" : "Flavio Poletti", "data" : [ [ @@ -278,21 +126,20 @@ "Blog", 2 ] - ], - "id" : "Flavio Poletti" + ] }, { + "id" : "James Raspass", + "name" : "James Raspass", "data" : [ [ "Raku", 1 ] - ], - "id" : "James Raspass", - "name" : "James Raspass" + ] }, { - "name" : "James Smith", + "id" : "James Smith", "data" : [ [ "Perl", @@ -303,11 +150,11 @@ 1 ] ], - "id" : "James Smith" + "name" : "James Smith" }, { - "name" : "Jan Krnavek", "id" : "Jan Krnavek", + "name" : "Jan Krnavek", "data" : [ [ "Raku", @@ -316,14 +163,14 @@ ] }, { + "id" : "Jorg Sommrey", "name" : "Jorg Sommrey", "data" : [ [ "Perl", 2 ] - ], - "id" : "Jorg Sommrey" + ] }, { "data" : [ @@ -340,22 +187,22 @@ 1 ] ], - "id" : "Laurent Rosenfeld", - "name" : "Laurent Rosenfeld" + "name" : "Laurent Rosenfeld", + "id" : "Laurent Rosenfeld" }, { - "name" : "Lubos Kolouch", - "id" : "Lubos Kolouch", "data" : [ [ "Perl", 1 ] - ] + ], + "name" : "Lubos Kolouch", + "id" : "Lubos Kolouch" }, { - "name" : "Luca Ferrari", "id" : "Luca Ferrari", + "name" : "Luca Ferrari", "data" : [ [ "Raku", @@ -369,13 +216,13 @@ }, { "id" : "Mark Anderson", + "name" : "Mark Anderson", "data" : [ [ "Raku", 2 ] - ], - "name" : "Mark Anderson" + ] }, { "name" : "Matthew Neleigh", @@ -388,27 +235,37 @@ "id" : "Matthew Neleigh" }, { - "id" : "Niels van Dijke", + "name" : "Niels van Dijke", "data" : [ [ "Perl", 2 ] ], - "name" : "Niels van Dijke" + "id" : "Niels van Dijke" }, { + "id" : "Olivier Delouya", + "name" : "Olivier Delouya", "data" : [ [ "Perl", 2 ] - ], - "id" : "Olivier Delouya", - "name" : "Olivier Delouya" + ] }, { - "name" : "Roger Bell_West", + "id" : "Pete Houston", + "name" : "Pete Houston", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "id" : "Roger Bell_West", "data" : [ [ "Perl", @@ -423,7 +280,7 @@ 1 ] ], - "id" : "Roger Bell_West" + "name" : "Roger Bell_West" }, { "data" : [ @@ -432,12 +289,11 @@ 1 ] ], - "id" : "Simon Proctor", - "name" : "Simon Proctor" + "name" : "Simon Proctor", + "id" : "Simon Proctor" }, { "name" : "Ulrich Rieke", - "id" : "Ulrich Rieke", "data" : [ [ "Perl", @@ -447,10 +303,11 @@ "Raku", 2 ] - ] + ], + "id" : "Ulrich Rieke" }, { - "name" : "W. Luis Mochan", + "id" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -461,34 +318,192 @@ 1 ] ], - "id" : "W. Luis Mochan" + "name" : "W. Luis Mochan" }, { - "id" : "Wanderdoc", + "name" : "Wanderdoc", "data" : [ [ "Perl", 2 ] ], - "name" : "Wanderdoc" + "id" : "Wanderdoc" } ] }, - "chart" : { - "type" : "column" + "legend" : { + "enabled" : 0 }, "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/>" + "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", + "followPointer" : 1 }, "yAxis" : { "title" : { "text" : "Total Solutions" } }, + "title" : { + "text" : "The Weekly Challenge - 132" + }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + } + } + }, "xAxis" : { "type" : "category" + }, + "series" : [ + { + "data" : [ + { + "drilldown" : "Abigail", + "y" : 4, + "name" : "Abigail" + }, + { + "drilldown" : "Adam Russell", + "name" : "Adam Russell", + "y" : 1 + }, + { + "name" : "Arne Sommer", + "drilldown" : "Arne Sommer", + "y" : 3 + }, + { + "drilldown" : "Athanasius", + "name" : "Athanasius", + "y" : 2 + }, + { + "name" : "Ben Davies", + "drilldown" : "Ben Davies", + "y" : 2 + }, + { + "drilldown" : "Cheok-Yin Fung", + "name" : "Cheok-Yin Fung", + "y" : 1 + }, + { + "y" : 3, + "drilldown" : "Dave Jacoby", + "name" : "Dave Jacoby" + }, + { + "y" : 2, + "drilldown" : "Duncan C. White", + "name" : "Duncan C. White" + }, + { + "y" : 2, + "drilldown" : "E. Choroba", + "name" : "E. Choroba" + }, + { + "drilldown" : "Flavio Poletti", + "y" : 6, + "name" : "Flavio Poletti" + }, + { + "y" : 1, + "drilldown" : "James Raspass", + "name" : "James Raspass" + }, + { + "drilldown" : "James Smith", + "y" : 3, + "name" : "James Smith" + }, + { + "drilldown" : "Jan Krnavek", + "name" : "Jan Krnavek", + "y" : 1 + }, + { + "drilldown" : "Jorg Sommrey", + "name" : "Jorg Sommrey", + "y" : 2 + }, + { + "drilldown" : "Laurent Rosenfeld", + "y" : 5, + "name" : "Laurent Rosenfeld" + }, + { + "y" : 1, + "drilldown" : "Lubos Kolouch", + "name" : "Lubos Kolouch" + }, + { + "drilldown" : "Luca Ferrari", + "y" : 4, + "name" : "Luca Ferrari" + }, + { + "name" : "Mark Anderson", + "drilldown" : "Mark Anderson", + "y" : 2 + }, + { + "name" : "Matthew Neleigh", + "drilldown" : "Matthew Neleigh", + "y" : 2 + }, + { + "name" : "Niels van Dijke", + "drilldown" : "Niels van Dijke", + "y" : 2 + }, + { + "drilldown" : "Olivier Delouya", + "y" : 2, + "name" : "Olivier Delouya" + }, + { + "drilldown" : "Pete Houston", + "name" : "Pete Houston", + "y" : 2 + }, + { + "y" : 5, + "drilldown" : "Roger Bell_West", + "name" : "Roger Bell_West" + }, + { + "y" : 1, + "drilldown" : "Simon Proctor", + "name" : "Simon Proctor" + }, + { + "y" : 3, + "drilldown" : "Ulrich Rieke", + "name" : "Ulrich Rieke" + }, + { + "name" : "W. Luis Mochan", + "drilldown" : "W. Luis Mochan", + "y" : 3 + }, + { + "name" : "Wanderdoc", + "drilldown" : "Wanderdoc", + "y" : 2 + } + ], + "name" : "The Weekly Challenge - 132", + "colorByPoint" : 1 + } + ], + "subtitle" : { + "text" : "[Champions: 27] Last updated at 2021-10-03 23:47:36 GMT" } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 5bd33d021c..b0a618eec3 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,19 +1,22 @@ { + "legend" : { + "enabled" : "false" + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "yAxis" : { + "min" : 0, + "title" : { + "text" : null + } + }, + "chart" : { + "type" : "column" + }, "series" : [ { "name" : "Contributions", - "dataLabels" : { - "format" : "{point.y:.0f}", - "color" : "#FFFFFF", - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - }, - "enabled" : "true", - "align" : "right", - "y" : 10, - "rotation" : -90 - }, "data" : [ [ "Blog", @@ -21,43 +24,40 @@ ], [ "Perl", - 6295 + 6297 ], [ "Raku", 3862 ] - ] + ], + "dataLabels" : { + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + }, + "enabled" : "true", + "rotation" : -90, + "y" : 10, + "format" : "{point.y:.0f}", + "align" : "right", + "color" : "#FFFFFF" + } } ], - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - }, "xAxis" : { - "type" : "category", "labels" : { "style" : { "fontSize" : "13px", "fontFamily" : "Verdana, sans-serif" } - } - }, - "yAxis" : { - "min" : 0, - "title" : { - "text" : null - } + }, + "type" : "category" }, - "chart" : { - "type" : "column" + "subtitle" : { + "text" : "Last updated at 2021-10-03 23:47:36 GMT" }, "title" : { "text" : "The Weekly Challenge Contributions [2019 - 2021]" - }, - "subtitle" : { - "text" : "Last updated at 2021-10-03 23:42:39 GMT" - }, - "legend" : { - "enabled" : "false" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 7988bb735c..57952bf234 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,12 +1,23 @@ { - "title" : { - "text" : "The Weekly Challenge Language" + "chart" : { + "type" : "column" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "tooltip" : { + "headerFormat" : "<span style=\"font-size:11px\"></span>", + "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>", + "followPointer" : "true" + }, + "legend" : { + "enabled" : "false" }, "drilldown" : { "series" : [ { - "name" : "001", - "id" : "001", "data" : [ [ "Perl", @@ -20,9 +31,12 @@ "Blog", 11 ] - ] + ], + "name" : "001", + "id" : "001" }, { + "id" : "002", "data" : [ [ "Perl", @@ -37,10 +51,10 @@ 10 ] ], - "id" : "002", "name" : "002" }, { + "name" : "003", "data" : [ [ "Perl", @@ -55,12 +69,10 @@ 9 ] ], - "id" : "003", - "name" : "003" + "id" : "003" }, { "name" : "004", - "id" : "004", "data" : [ [ "Perl", @@ -74,10 +86,10 @@ "Blog", 10 ] - ] + ], + "id" : "004" }, { - "id" : "005", "data" : [ [ "Perl", @@ -92,11 +104,11 @@ 12 ] ], - "name" : "005" + "name" : "005", + "id" : "005" }, { "name" : "006", - "id" : "006", "data" : [ [ "Perl", @@ -110,10 +122,12 @@ "Blog", 7 ] - ] + ], + "id" : "006" }, { "id" : "007", + "name" : "007", "data" : [ [ "Perl", @@ -127,8 +141,7 @@ "Blog", 10 ] - ], - "name" : "007" + ] }, { "name" : "008", @@ -149,7 +162,6 @@ "id" : "008" }, { - "id" : "009", "data" : [ [ "Perl", @@ -164,11 +176,12 @@ 13 ] ], - "name" : "009" + "name" : "009", + "id" : "009" }, { - "name" : "010", "id" : "010", + "name" : "010", "data" : [ [ "Perl", @@ -203,7 +216,7 @@ "name" : "011" }, { - "name" : "012", + "id" : "012", "data" : [ [ "Perl", @@ -218,10 +231,9 @@ 11 ] ], - "id" : "012" + "name" : "012" }, { - "id" : "013", "data" : [ [ "Perl", @@ -236,9 +248,12 @@ 13 ] ], - "name" : "013" + "name" : "013", + "id" : "013" }, { + "id" : "014", + "name" : "014", "data" : [ [ "Perl", @@ -252,12 +267,11 @@ "Blog", 15 ] - ], - "id" : "014", - "name" : "014" + ] }, { |
