diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-01-09 19:38:28 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-01-09 19:38:28 +0000 |
| commit | bf0e37317122de0322d69b1c68bd07ccfc5b36a8 (patch) | |
| tree | 5031b453f163650bf08f28093e65bc5aa6873eab | |
| parent | 543c00b7aedce99655017c3920914302df649995 (diff) | |
| download | perlweeklychallenge-club-bf0e37317122de0322d69b1c68bd07ccfc5b36a8.tar.gz perlweeklychallenge-club-bf0e37317122de0322d69b1c68bd07ccfc5b36a8.tar.bz2 perlweeklychallenge-club-bf0e37317122de0322d69b1c68bd07ccfc5b36a8.zip | |
- Added solutions by Pete Houston.
| -rwxr-xr-x | challenge-146/pete-houston/perl/ch-1.pl | 22 | ||||
| -rwxr-xr-x | challenge-146/pete-houston/perl/ch-2.pl | 96 | ||||
| -rw-r--r-- | stats/pwc-current.json | 437 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 56 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 2044 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 730 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 56 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 46 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 58 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 102 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 122 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 66 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 118 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 34 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 38 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 540 |
16 files changed, 2349 insertions, 2216 deletions
diff --git a/challenge-146/pete-houston/perl/ch-1.pl b/challenge-146/pete-houston/perl/ch-1.pl new file mode 100755 index 0000000000..78477cbaa7 --- /dev/null +++ b/challenge-146/pete-houston/perl/ch-1.pl @@ -0,0 +1,22 @@ +#!/usr/bin/env perl +#=============================================================================== +# +# FILE: 14601.pl +# +# USAGE: ./14601.pl [ N ] +# +# DESCRIPTION: Output the Nth prime (defaults to 10001) +# +# OPTIONS: N defaults to 10_001 if unspecified +# REQUIREMENTS: Math::Prime::Util, what else? +# AUTHOR: Pete Houston (pete), cpan@openstrike.co.uk +# ORGANIZATION: Openstrike +# VERSION: 1.0 +# CREATED: 05/01/22 +#=============================================================================== + +use strict; +use warnings; +use Math::Prime::Util 'nth_prime'; + +print nth_prime (shift // 10_001) . "\n"; diff --git a/challenge-146/pete-houston/perl/ch-2.pl b/challenge-146/pete-houston/perl/ch-2.pl new file mode 100755 index 0000000000..eafd0a7e2c --- /dev/null +++ b/challenge-146/pete-houston/perl/ch-2.pl @@ -0,0 +1,96 @@ +#!/usr/bin/env perl +#=============================================================================== +# +# FILE: 14602.pl +# +# USAGE: ./14602.pl N/M +# +# DESCRIPTION: Print out 2 ancestors of the tree value matching the +# argument. +# +# REQUIREMENTS: Class::Tiny +# NOTES: The tree is really unnecessary here. See 14602b.pl for +# alternative approach without one. +# AUTHOR: Pete Houston (pete), cpan@openstrike.co.uk +# ORGANIZATION: Openstrike +# VERSION: 1.0 +# CREATED: 03/01/22 +#=============================================================================== + +use strict; +use warnings; + +# Each pair of children have values which are: +# Left: parent numerator over sum of parent numerator and denominator +# Right: sum of parent numerator and denominator over parent denominator + +package Node; + +use Class::Tiny qw/lchild rchild parent value/; + +sub BUILD { + + #my ($class, $value, $r, $maxdepth, $parent) = @_; + my ($self, $args) = @_; + my $r = $args->{row}; + my $maxdepth = $args->{maxdepth}; + + # Build tree from 1/1 + unless ($args->{row}) { + $r //= 0; + $self->value ('1/1') unless defined $self->value; + } + + # Add children if we are not the bottom row + if ($r < $maxdepth) { + my ($num, $dom) = split /\//, $self->value; + my $sum = $num + $dom; + my %childargs = ( + row => $r + 1, + maxdepth => $maxdepth, + parent => $self + ); + $self->lchild (Node->new (value => "$num/$sum", %childargs)); + $self->rchild (Node->new (value => "$sum/$dom", %childargs)); + } + +} + +# Retrieve or calculate the minimum path downwards from here. +sub find_by_value { + my ($self, $value) = @_; + return $self if $self->value eq $value; + for my $child ($self->lchild, $self->rchild) { + next unless defined $child; + my $res = $child->find_by_value ($value); + return $res if defined $res; + } + return; +} + +package main; + +my $root = Node->new (value => '1/1', row => 0, maxdepth => 4); + +my $v = shift; +my $one = $root->find_by_value ($v); + +unless (defined $one) { + print "No match for value '$v' found\n"; + exit; +} + +my $parent = $one->parent; +unless (defined $parent) { + print "No parent found\n"; + exit; +} +print "parent = '" . $parent->value . "' and "; + +my $gparent = $parent->parent; +unless (defined $gparent) { + print "no grandparent found\n"; + exit; +} +print "grandparent = '" . $gparent->value . "'\n"; + diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 7f356c5fbe..a01f2a62fa 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,15 +1,169 @@ { - "chart" : { - "type" : "column" + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "legend" : { + "enabled" : 0 }, "subtitle" : { - "text" : "[Champions: 26] Last updated at 2022-01-09 11:57:46 GMT" + "text" : "[Champions: 27] Last updated at 2022-01-09 19:36:56 GMT" + }, + "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/>" + }, + "series" : [ + { + "colorByPoint" : 1, + "data" : [ + { + "y" : 4, + "drilldown" : "Abigail", + "name" : "Abigail" + }, + { + "drilldown" : "Andrew Shitov", + "y" : 1, + "name" : "Andrew Shitov" + }, + { + "name" : "Andrezgz", + "y" : 2, + "drilldown" : "Andrezgz" + }, + { + "drilldown" : "Arne Sommer", + "y" : 5, + "name" : "Arne Sommer" + }, + { + "name" : "Athanasius", + "y" : 4, + "drilldown" : "Athanasius" + }, + { + "name" : "Dave Jacoby", + "y" : 3, + "drilldown" : "Dave Jacoby" + }, + { + "drilldown" : "Duncan C. White", + "y" : 2, + "name" : "Duncan C. White" + }, + { + "name" : "E. Choroba", + "y" : 2, + "drilldown" : "E. Choroba" + }, + { + "name" : "Feng Chang", + "drilldown" : "Feng Chang", + "y" : 2 + }, + { + "name" : "Flavio Poletti", + "y" : 6, + "drilldown" : "Flavio Poletti" + }, + { + "drilldown" : "James Smith", + "y" : 3, + "name" : "James Smith" + }, + { + "name" : "Jan Krnavek", + "y" : 2, + "drilldown" : "Jan Krnavek" + }, + { + "name" : "Jorg Sommrey", + "drilldown" : "Jorg Sommrey", + "y" : 1 + }, + { + "name" : "Laurent Rosenfeld", + "drilldown" : "Laurent Rosenfeld", + "y" : 5 + }, + { + "drilldown" : "Luca Ferrari", + "y" : 6, + "name" : "Luca Ferrari" + }, + { + "drilldown" : "Mark Anderson", + "y" : 2, + "name" : "Mark Anderson" + }, + { + "name" : "Mark Senn", + "drilldown" : "Mark Senn", + "y" : 4 + }, + { + "name" : "Mohammad S Anwar", + "y" : 2, + "drilldown" : "Mohammad S Anwar" + }, + { + "drilldown" : "Niels van Dijke", + "y" : 2, + "name" : "Niels van Dijke" + }, + { + "drilldown" : "Pete Houston", + "y" : 2, + "name" : "Pete Houston" + }, + { + "name" : "Peter Campbell Smith", + "drilldown" : "Peter Campbell Smith", + "y" : 3 + }, + { + "name" : "Robert DiCicco", + "y" : 2, + "drilldown" : "Robert DiCicco" + }, + { + "name" : "Roger Bell_West", + "y" : 5, + "drilldown" : "Roger Bell_West" + }, + { + "drilldown" : "Simon Green", + "y" : 3, + "name" : "Simon Green" + }, + { + "drilldown" : "Simon Proctor", + "y" : 2, + "name" : "Simon Proctor" + }, + { + "name" : "Ulrich Rieke", + "drilldown" : "Ulrich Rieke", + "y" : 4 + }, + { + "y" : 3, + "drilldown" : "W. Luis Mochan", + "name" : "W. Luis Mochan" + } + ], + "name" : "The Weekly Challenge - 146" + } + ], + "chart" : { + "type" : "column" }, "drilldown" : { "series" : [ { - "id" : "Abigail", - "name" : "Abigail", "data" : [ [ "Perl", @@ -19,17 +173,19 @@ "Blog", 2 ] - ] + ], + "name" : "Abigail", + "id" : "Abigail" }, { + "name" : "Andrew Shitov", + "id" : "Andrew Shitov", "data" : [ [ "Raku", 1 ] - ], - "name" : "Andrew Shitov", - "id" : "Andrew Shitov" + ] }, { "id" : "Andrezgz", @@ -60,7 +216,6 @@ "id" : "Arne Sommer" }, { - "name" : "Athanasius", "data" : [ [ "Perl", @@ -71,10 +226,10 @@ 2 ] ], + "name" : "Athanasius", "id" : "Athanasius" }, { - "name" : "Dave Jacoby", "data" : [ [ "Perl", @@ -85,16 +240,17 @@ 1 ] ], + "name" : "Dave Jacoby", "id" : "Dave Jacoby" }, { - "id" : "Duncan C. White", "data" : [ [ "Perl", 2 ] ], + "id" : "Duncan C. White", "name" : "Duncan C. White" }, { @@ -109,15 +265,17 @@ }, { "id" : "Feng Chang", + "name" : "Feng Chang", "data" : [ [ "Raku", 2 ] - ], - "name" : "Feng Chang" + ] }, { + "name" : "Flavio Poletti", + "id" : "Flavio Poletti", "data" : [ [ "Perl", @@ -131,13 +289,9 @@ "Blog", 2 ] - ], - "name" : "Flavio Poletti", - "id" : "Flavio Poletti" + ] }, { - "id" : "James Smith", - "name" : "James Smith", "data" : [ [ "Perl", @@ -147,30 +301,31 @@ "Blog", 1 ] - ] + ], + "name" : "James Smith", + "id" : "James Smith" }, { - "id" : "Jan Krnavek", - "name" : "Jan Krnavek", "data" : [ [ "Raku", 2 ] - ] + ], + "id" : "Jan Krnavek", + "name" : "Jan Krnavek" }, { - "name" : "Jorg Sommrey", "data" : [ [ "Perl", 1 ] ], + "name" : "Jorg Sommrey", "id" : "Jorg Sommrey" }, { - "name" : "Laurent Rosenfeld", "data" : [ [ "Perl", @@ -185,9 +340,12 @@ 1 ] ], - "id" : "Laurent Rosenfeld" + "id" : "Laurent Rosenfeld", + "name" : "Laurent Rosenfeld" }, { + "name" : "Luca Ferrari", + "id" : "Luca Ferrari", "data" : [ [ "Raku", @@ -197,22 +355,19 @@ "Blog", 4 ] - ], - "name" : "Luca Ferrari", - "id" : "Luca Ferrari" + ] }, { + "id" : "Mark Anderson", "name" : "Mark Anderson", "data" : [ [ "Raku", 2 ] - ], - "id" : "Mark Anderson" + ] }, { - "id" : "Mark Senn", "data" : [ [ "Raku", @@ -223,9 +378,12 @@ 2 ] ], - "name" : "Mark Senn" + "name" : "Mark Senn", + "id" : "Mark Senn" }, { + "name" : "Mohammad S Anwar", + "id" : "Mohammad S Anwar", "data" : [ [ "Perl", @@ -235,9 +393,7 @@ "Raku", 1 ] - ], - "name" : "Mohammad S Anwar", - "id" : "Mohammad S Anwar" + ] }, { "data" : [ @@ -254,27 +410,38 @@ [ "Perl", 2 + ] + ], + "id" : "Pete Houston", + "name" : "Pete Houston" + }, + { + "id" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith", + "data" : [ + [ + "Perl", + 2 ], [ "Blog", 1 ] - ], - "name" : "Peter Campbell Smith", - "id" : "Peter Campbell Smith" + ] }, { - "name" : "Robert DiCicco", "data" : [ [ "Perl", 2 ] ], + "name" : "Robert DiCicco", "id" : "Robert DiCicco" }, { "name" : "Roger Bell_West", + "id" : "Roger Bell_West", "data" : [ [ "Perl", @@ -288,11 +455,11 @@ "Blog", 1 ] - ], - "id" : "Roger Bell_West" + ] }, { "name" : "Simon Green", + "id" : "Simon Green", "data" : [ [ "Perl", @@ -302,22 +469,19 @@ "Blog", 1 ] - ], - "id" : "Simon Green" + ] }, { + "id" : "Simon Proctor", + "name" : "Simon Proctor", "data" : [ [ "Raku", 2 ] - ], - "name" : "Simon Proctor", - "id" : "Simon Proctor" + ] }, { - "id" : "Ulrich Rieke", - "name" : "Ulrich Rieke", "data" : [ [ "Perl", @@ -327,11 +491,11 @@ "Raku", 2 ] - ] + ], + "name" : "Ulrich Rieke", + "id" : "Ulrich Rieke" }, { - "id" : "W. Luis Mochan", - "name" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -341,174 +505,25 @@ "Blog", 1 ] - ] + ], + "name" : "W. Luis Mochan", + "id" : "W. Luis Mochan" } ] }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "title" : { - "text" : "The Weekly Challenge - 146" - }, "plotOptions" : { "series" : { - "borderWidth" : 0, "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - } - } - }, - "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/>" - }, - "series" : [ - { - "name" : "The Weekly Challenge - 146", - "data" : [ - { - "y" : 4, - "drilldown" : "Abigail", - "name" : "Abigail" - }, - { - "y" : 1, - "drilldown" : "Andrew Shitov", - "name" : "Andrew Shitov" - }, - { - "drilldown" : "Andrezgz", - "y" : 2, - "name" : "Andrezgz" - }, - { - "y" : 5, - "drilldown" : "Arne Sommer", - "name" : "Arne Sommer" - }, - { - "drilldown" : "Athanasius", - "y" : 4, - "name" : "Athanasius" - }, - { - "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" : "Feng Chang", - "y" : 2, - "name" : "Feng Chang" - }, - { - "y" : 6, - "drilldown" : "Flavio Poletti", - "name" : "Flavio Poletti" - }, - { - "y" : 3, - "drilldown" : "James Smith", - "name" : "James Smith" - }, - { - "drilldown" : "Jan Krnavek", - "y" : 2, - "name" : "Jan Krnavek" - }, - { - "y" : 1, - "drilldown" : "Jorg Sommrey", - "name" : "Jorg Sommrey" - }, - { - "name" : "Laurent Rosenfeld", - "drilldown" : "Laurent Rosenfeld", - "y" : 5 - }, - { - "drilldown" : "Luca Ferrari", - "y" : 6, - "name" : "Luca Ferrari" - }, - { - "y" : 2, - "drilldown" : "Mark Anderson", - "name" : "Mark Anderson" - }, - { - "drilldown" : "Mark Senn", - "y" : 4, - "name" : "Mark Senn" - }, - { - "name" : "Mohammad S Anwar", - "y" : 2, - "drilldown" : "Mohammad S Anwar" - }, - { - "name" : "Niels van Dijke", - "y" : 2, - "drilldown" : "Niels van Dijke" - }, - { - "y" : 3, - "drilldown" : "Peter Campbell Smith", - "name" : "Peter Campbell Smith" - }, - { - "drilldown" : "Robert DiCicco", - "y" : 2, - "name" : "Robert DiCicco" - }, - { - "name" : "Roger Bell_West", - "y" : 5, - "drilldown" : "Roger Bell_West" - }, - { - "name" : "Simon Green", - "y" : 3, - "drilldown" : "Simon Green" - }, - { - "name" : "Simon Proctor", - "drilldown" : "Simon Proctor", - "y" : 2 - }, - { - "name" : "Ulrich Rieke", - "y" : 4, - "drilldown" : "Ulrich Rieke" - }, - { - "y" : 3, - "drilldown" : "W. Luis Mochan", - "name" : "W. Luis Mochan" - } - ], - "colorByPoint" : 1 + "format" : "{point.y}", + "enabled" : 1 + }, + "borderWidth" : 0 } - ], - "legend" : { - "enabled" : 0 }, "xAxis" : { "type" : "category" + }, + "title" : { + "text" : "The Weekly Challenge - 146" } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 0501096812..1e71fa299f 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,34 +1,36 @@ { - "title" : { - "text" : "The Weekly Challenge Contributions [2019 - 2021]" - }, - "yAxis" : { - "min" : 0, - "title" : { - "text" : null - } - }, - "subtitle" : { - "text" : "Last updated at 2022-01-09 11:57:46 GMT" - }, - "chart" : { - "type" : "column" - }, "xAxis" : { "type" : "category", "labels" : { "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" } } }, + "chart" : { + "type" : "column" + }, + "title" : { + "text" : "The Weekly Challenge Contributions [2019 - 2021]" + }, "legend" : { "enabled" : "false" }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "subtitle" : { + "text" : "Last updated at 2022-01-09 19:36:56 GMT" + }, + "yAxis" : { + "title" : { + "text" : null + }, + "min" : 0 + }, "series" : [ { - "name" : "Contributions", "data" : [ [ "Blog", @@ -36,7 +38,7 @@ ], [ "Perl", - 7043 + 7045 ], [ "Raku", @@ -44,20 +46,18 @@ ] ], "dataLabels" : { - "align" : "right", "style" : { "fontSize" : "13px", "fontFamily" : "Verdana, sans-serif" }, - "y" : 10, - "format" : "{point.y:.0f}", "color" : "#FFFFFF", + "format" : "{point.y:.0f}", + "rotation" : -90, "enabled" : "true", - "rotation" : -90 - } + "y" : 10, + "align" : "right" + }, + "name" : "Contributions" } - ], - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - } + ] } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 628aebaa92..dd97b3cd8e 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,27 +1,764 @@ { - "title" : { - "text" : "The Weekly Challenge Language" - }, - "plotOptions" : { - "series" : { - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 - } - }, - "chart" : { - "type" : "column" + "legend" : { + "enabled" : "false" }, "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2022-01-09 11:57:46 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2022-01-09 19:36:56 GMT" + }, + "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" }, "yAxis" : { "title" : { "text" : "Total Solutions" } }, + "series" : [ + { + "data" : [ + { + "y" : 161, + "drilldown" : "001", + "name" : "#001" + }, + { + "drilldown" : "002", + "y" : 125, + "name" : "#002" + }, + { + "name" : "#003", + "drilldown" : "003", + "y" : 83 + }, + { + "y" : 99, + "drilldown" : "004", + "name" : "#004" + }, + { + "y" : 78, + "drilldown" : "005", + "name" : "#005" + }, + { + "drilldown" : "006", + "y" : 58, + "name" : "#006" + }, + { + "y" : 64, + "drilldown" : "007", + "name" : "#007" + }, + { + "y" : 78, + "drilldown" : "008", + "name" : "#008" + }, + { + "name" : "#009", + "drilldown" : "009", + "y" : 76 + }, + { + "name" : "#010", + "y" : 65, + "drilldown" : "010" + }, + { + "y" : 85, + "drilldown" : "011", + "name" : "#011" + }, + { + "name" : "#012", + "y" : 89, + "drilldown" : "012" + }, + { + "name" : "#013", + "y" : 85, + "drilldown" : "013" + }, + { + "name" : "#014", + "drilldown" : "014", + "y" : 101 + }, + { + "drilldown" : "015", + "y" : 99, + "name" : "#015" + }, + { + "y" : 71, + "drilldown" : "016", + "name" : "#016" + }, + { + "drilldown" : "017", + "y" : 84, + "name" : "#017" + }, + { + "drilldown" : "018", + "y" : 81, + "name" : "#018" + }, + { + "name" : "#019", + "y" : 103, + "drilldown" : "019" + }, + { + "name" : "#020", + "y" : 101, + "drilldown" : "020" + }, + { + "y" : 72, + "drilldown" : "021", + "name" : "#021" + }, + { + "y" : 68, + "drilldown" : "022", + "name" : "#022" + }, + { + "name" : "#023", + "drilldown" : "023", + "y" : 97 + }, + { + "drilldown" : "024", + "y" : 75, + "name" : "#024" + }, + { + "y" : 59, + "drilldown" : "025", + "name" : "#025" + }, + { + "drilldown" : "026", + "y" : 74, + "name" : "#026" + }, + { + "name" : "#027", + "drilldown" : "027", + "y" : 62 + }, + |
