diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-09-12 20:18:34 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-09-12 20:18:34 +0100 |
| commit | b7027b9a838c13ab54de3baa7ca520cd33219763 (patch) | |
| tree | 53a087c79a3fdde2bf63d326f5bc139a5027eafb | |
| parent | b5126aad694761aee94fcfeb8ab0d3c8a395ff1c (diff) | |
| download | perlweeklychallenge-club-b7027b9a838c13ab54de3baa7ca520cd33219763.tar.gz perlweeklychallenge-club-b7027b9a838c13ab54de3baa7ca520cd33219763.tar.bz2 perlweeklychallenge-club-b7027b9a838c13ab54de3baa7ca520cd33219763.zip | |
- Added solutions by Pete Houston.
| -rw-r--r-- | challenge-077/pete-houston/perl/ch-1.pl | 45 | ||||
| -rw-r--r-- | challenge-077/pete-houston/perl/ch-2.pl | 70 | ||||
| -rw-r--r-- | stats/pwc-current.json | 189 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 80 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 538 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 426 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 112 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 128 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 42 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 126 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 50 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 126 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 38 |
14 files changed, 1070 insertions, 940 deletions
diff --git a/challenge-077/pete-houston/perl/ch-1.pl b/challenge-077/pete-houston/perl/ch-1.pl new file mode 100644 index 0000000000..8e31ef75df --- /dev/null +++ b/challenge-077/pete-houston/perl/ch-1.pl @@ -0,0 +1,45 @@ +#!/usr/bin/env perl +#=============================================================================== +# +# FILE: 7701.pl +# +# USAGE: ./7701.pl N +# +# DESCRIPTION: Outputs all sums of unique Fibonacci numbers to make N +# +# REQUIREMENTS: Algorithm::Knapsack, Params::Util, List::Util +# AUTHOR: Pete Houston (pete), cpan@openstrike.co.uk +# ORGANIZATION: Openstrike +# VERSION: 1.0 +# CREATED: 07/09/20 +#=============================================================================== + +use strict; +use warnings; +use Algorithm::Knapsack; +use Params::Util '_POSINT'; +use List::Util 'sum'; + +# Validate input +my $tot = shift; +die "Argument must be a whole number.\n" unless _POSINT $tot; + +# Construct a big enough Fibonacci sequence. No duplicates! +my @fib = (1, 2); +push @fib, $fib[-1] + $fib[-2] while $fib[-1] + $fib[-2] <= $tot; + +# Process +my $sack = Algorithm::Knapsack->new ( + capacity => $tot, + weights => \@fib, +); +$sack->compute; + +# Output +my $combos = 0; +for my $fit ($sack->solutions) { + next unless sum (@fib[@$fit]) == $tot; + print join (' + ', @fib[@$fit]) . " = $tot\n"; + $combos++; +} +print "0\n" unless $combos; diff --git a/challenge-077/pete-houston/perl/ch-2.pl b/challenge-077/pete-houston/perl/ch-2.pl new file mode 100644 index 0000000000..bda3c2a0ba --- /dev/null +++ b/challenge-077/pete-houston/perl/ch-2.pl @@ -0,0 +1,70 @@ +#!/usr/bin/env perl +#=============================================================================== +# +# FILE: 7702.pl +# +# USAGE: ./7702.pl GRIDFILE +# +# DESCRIPTION: Find Xs with no X neighbours +# +# REQUIREMENTS: Path::Tiny, Lingua::EN::Inflexion, Lingua::EN::Nums2Words +# NOTES: In addition to the number found, also prints locations +# AUTHOR: Pete Houston (pete), cpan@openstrike.co.uk +# ORGANIZATION: Openstrike +# VERSION: 1.0 +# CREATED: 12/09/20 +#=============================================================================== + +use strict; +use warnings; +use autodie; + +use Path::Tiny 'path'; +use Lingua::EN::Inflexion; + +my @grid = read_grid (shift); +my @xmess = find_solo_x (@grid); +print scalar (@xmess), "\n", @xmess; + +sub read_grid { + my @rows = path(shift)->lines ({chomp => 1}); + tr/OX//dc, $_ = [ split //, $_ ] for @rows; + return @rows; +} + +sub find_solo_x { + my @grid = @_; + my $maxrow = $#grid; + my $maxcol = $#{$grid[0]}; + die "Grid is not rectangular.\n" if grep { $#$_ != $maxcol } @grid; + my @solos; + for my $r (0 .. $maxrow) { + for my $c (0 .. $maxcol) { + next unless $grid[$r][$c] eq 'X'; + push @solos, mess ($r, $c, $#solos) + if all_os_around (\@grid, $r, $c); + } + } + return @solos; +} + +sub all_os_around { + my ($grid, $r, $c) = @_; + for my $i ($r - 1 .. $r + 1) { + next unless $i >= 0 && defined $grid->[$i]; + for my $j ($c - 1 .. $c + 1) { + next unless $j >= 0 && defined $grid->[$i][$j]; + next if $i == $r && $j == $c; + return if $grid->[$i][$j] eq 'X'; + } + } + return 1; +} + +sub mess { + my ($r, $c, $tot) = @_; + $tot += 2; + $r += 1; + $c += 1; + return ucfirst inflect ("<#ow:$tot> X found at Row $r Col $c.\n"); +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 694b906a29..4bd4997492 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,38 +1,36 @@ { - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } + "xAxis" : { + "type" : "category" }, "subtitle" : { - "text" : "[Champions: 22] Last updated at 2020-09-12 11:47:16 GMT" + "text" : "[Champions: 23] Last updated at 2020-09-12 19:18:11 GMT" }, - "title" : { - "text" : "Perl Weekly Challenge - 077" - }, - "plotOptions" : { - "series" : { - "borderWidth" : 0, - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - } - } - }, - "chart" : { - "type" : "column" + "legend" : { + "enabled" : 0 }, "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/>" }, - "xAxis" : { - "type" : "category" + "plotOptions" : { + "series" : { + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + }, + "borderWidth" : 0 + } + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } }, "drilldown" : { "series" : [ { + "id" : "Andinus", "name" : "Andinus", "data" : [ [ @@ -43,11 +41,11 @@ "Blog", 1 ] - ], - "id" : "Andinus" + ] }, { "id" : "Andrew Shitov", + "name" : "Andrew Shitov", "data" : [ [ "Perl", @@ -61,10 +59,10 @@ "Blog", 2 ] - ], - "name" : "Andrew Shitov" + ] }, { + "id" : "Arne Sommer", "data" : [ [ "Raku", @@ -75,58 +73,57 @@ 1 ] ], - "id" : "Arne Sommer", "name" : "Arne Sommer" }, { - "id" : "Colin Crain", "data" : [ [ "Blog", 1 ] ], - "name" : "Colin Crain" + "name" : "Colin Crain", + "id" : "Colin Crain" }, { - "id" : "Dave Jacoby", + "name" : "Dave Jacoby", "data" : [ [ "Perl", 2 ] ], - "name" : "Dave Jacoby" + "id" : "Dave Jacoby" }, { - "id" : "E. Choroba", + "name" : "E. Choroba", "data" : [ [ "Perl", 2 ] ], - "name" : "E. Choroba" + "id" : "E. Choroba" }, { - "name" : "Feng Chang", + "id" : "Feng Chang", "data" : [ [ "Raku", 2 ] ], - "id" : "Feng Chang" + "name" : "Feng Chang" }, { - "id" : "Jorg Sommrey", "data" : [ [ "Perl", 2 ] ], - "name" : "Jorg Sommrey" + "name" : "Jorg Sommrey", + "id" : "Jorg Sommrey" }, { "id" : "Laurent Rosenfeld", @@ -147,28 +144,28 @@ "name" : "Laurent Rosenfeld" }, { - "id" : "Lubos Kolouch", "data" : [ [ "Perl", 1 ] ], - "name" : "Lubos Kolouch" + "name" : "Lubos Kolouch", + "id" : "Lubos Kolouch" }, { - "name" : "Mark Anderson", "data" : [ [ "Raku", 2 ] ], + "name" : "Mark Anderson", "id" : "Mark Anderson" }, { - "name" : "Markus Holzer", "id" : "Markus Holzer", + "name" : "Markus Holzer", "data" : [ [ "Raku", @@ -178,6 +175,7 @@ }, { "id" : "Mohammad S Anwar", + "name" : "Mohammad S Anwar", "data" : [ [ "Perl", @@ -187,10 +185,10 @@ "Raku", 2 ] - ], - "name" : "Mohammad S Anwar" + ] }, { + "id" : "Myoungjin Jeon", "data" : [ [ "Perl", @@ -201,17 +199,16 @@ 2 ] ], - "id" : "Myoungjin Jeon", "name" : "Myoungjin Jeon" }, { - "name" : "Niels van Dijke", "data" : [ [ "Perl", 2 ] ], + "name" : "Niels van Dijke", "id" : "Niels van Dijke" }, { @@ -221,17 +218,17 @@ 2 ] ], - "id" : "Nuno Vieira", - "name" : "Nuno Vieira" + "name" : "Nuno Vieira", + "id" : "Nuno Vieira" }, { - "name" : "P6steve", "data" : [ [ "Raku", 2 ] ], + "name" : "P6steve", "id" : "P6steve" }, { @@ -239,6 +236,17 @@ [ "Perl", 2 + ] + ], + "name" : "Pete Houston", + "id" : "Pete Houston" + }, + { + "id" : "Roger Bell_West", + "data" : [ + [ + "Perl", + 2 ], [ "Raku", @@ -249,10 +257,10 @@ 1 ] ], - "id" : "Roger Bell_West", "name" : "Roger Bell_West" }, { + "id" : "Simon Green", "name" : "Simon Green", "data" : [ [ @@ -263,12 +271,11 @@ "Blog", 1 ] - ], - "id" : "Simon Green" + ] }, { - "name" : "Simon Proctor", "id" : "Simon Proctor", + "name" : "Simon Proctor", "data" : [ [ "Raku", @@ -277,6 +284,7 @@ ] }, { + "name" : "Ulrich Rieke", "data" : [ [ "Perl", @@ -287,11 +295,9 @@ 1 ] ], - "id" : "Ulrich Rieke", - "name" : "Ulrich Rieke" + "id" : "Ulrich Rieke" }, { - "name" : "Walt Mankowski", "id" : "Walt Mankowski", "data" : [ [ @@ -302,13 +308,11 @@ "Blog", 1 ] - ] + ], + "name" : "Walt Mankowski" } ] }, - "legend" : { - "enabled" : 0 - }, "series" : [ { "name" : "Perl Weekly Challenge - 077", @@ -319,13 +323,13 @@ "drilldown" : "Andinus" }, { - "drilldown" : "Andrew Shitov", "name" : "Andrew Shitov", + "drilldown" : "Andrew Shitov", "y" : 5 }, { - "name" : "Arne Sommer", "y" : 3, + "name" : "Arne Sommer", "drilldown" : "Arne Sommer" }, { @@ -335,43 +339,43 @@ }, { "name" : "Dave Jacoby", - "y" : 2, - "drilldown" : "Dave Jacoby" + "drilldown" : "Dave Jacoby", + "y" : 2 }, { - "y" : 2, + "drilldown" : "E. Choroba", "name" : "E. Choroba", - "drilldown" : "E. Choroba" + "y" : 2 }, { - "name" : "Feng Chang", "y" : 2, + "name" : "Feng Chang", "drilldown" : "Feng Chang" }, { - "name" : "Jorg Sommrey", "y" : 2, - "drilldown" : "Jorg Sommrey" + "drilldown" : "Jorg Sommrey", + "name" : "Jorg Sommrey" }, { - "drilldown" : "Laurent Rosenfeld", + "y" : 5, "name" : "Laurent Rosenfeld", - "y" : 5 + "drilldown" : "Laurent Rosenfeld" }, { - "name" : "Lubos Kolouch", "y" : 1, + "name" : "Lubos Kolouch", "drilldown" : "Lubos Kolouch" }, { "drilldown" : "Mark Anderson", - "y" : 2, - "name" : "Mark Anderson" + "name" : "Mark Anderson", + "y" : 2 }, { - "drilldown" : "Markus Holzer", + "y" : 1, "name" : "Markus Holzer", - "y" : 1 + "drilldown" : "Markus Holzer" }, { "drilldown" : "Mohammad S Anwar", @@ -380,8 +384,8 @@ }, { "name" : "Myoungjin Jeon", - "y" : 4, - "drilldown" : "Myoungjin Jeon" + "drilldown" : "Myoungjin Jeon", + "y" : 4 }, { "y" : 2, @@ -394,37 +398,48 @@ "drilldown" : "Nuno Vieira" }, { - "name" : "P6steve", "y" : 2, + "name" : "P6steve", "drilldown" : "P6steve" }, { - "drilldown" : "Roger Bell_West", + "name" : "Pete Houston", + "drilldown" : "Pete Houston", + "y" : 2 + }, + { "name" : "Roger Bell_West", + "drilldown" : "Roger Bell_West", "y" : 5 }, { - "drilldown" : "Simon Green", "y" : 3, - "name" : "Simon Green" + "name" : "Simon Green", + "drilldown" : "Simon Green" }, { + "y" : 2, "drilldown" : "Simon Proctor", - "name" : "Simon Proctor", - "y" : 2 + "name" : "Simon Proctor" }, { - "drilldown" : "Ulrich Rieke", "y" : 2, - "name" : "Ulrich Rieke" + "name" : "Ulrich Rieke", + "drilldown" : "Ulrich Rieke" }, { "y" : 3, - "name" : "Walt Mankowski", - "drilldown" : "Walt Mankowski" + "drilldown" : "Walt Mankowski", + "name" : "Walt Mankowski" } ], "colorByPoint" : 1 } - ] + ], + "chart" : { + "type" : "column" + }, + "title" : { + "text" : "Perl Weekly Challenge - 077" + } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 90d28020cd..35997d5670 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,37 +1,25 @@ { - "xAxis" : { - "labels" : { - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - } - }, - "type" : "category" - }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - }, - "chart" : { - "type" : "column" - }, "title" : { "text" : "Perl Weekly Challenge Contributions [2019 - 2020]" }, - "subtitle" : { - "text" : "Last updated at 2020-09-12 11:47:16 GMT" - }, - "yAxis" : { - "title" : { - "text" : null - }, - "min" : 0 - }, - "legend" : { - "enabled" : "false" + "chart" : { + "type" : "column" }, "series" : [ { "name" : "Contributions", + "dataLabels" : { + "enabled" : "true", + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + }, + "format" : "{point.y:.0f}", + "align" : "right", + "y" : 10, + "color" : "#FFFFFF", + "rotation" : -90 + }, "data" : [ [ "Blog", @@ -39,25 +27,37 @@ ], [ "Perl", - 3231 + 3233 ], [ "Raku", 2110 ] - ], - "dataLabels" : { - "rotation" : -90, - "format" : "{point.y:.0f}", - "enabled" : "true", - "color" : "#FFFFFF", - "align" : "right", - "y" : 10, - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - } + ] + } + ], + "yAxis" : { + "title" : { + "text" : null + }, + "min" : 0 + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "subtitle" : { + "text" : "Last updated at 2020-09-12 19:18:11 GMT" + }, + "legend" : { + "enabled" : "false" + }, + "xAxis" : { + "type" : "category", + "labels" : { + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" } } - ] + } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index a65d63948d..f82acc1d44 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,38 +1,37 @@ { - "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2020-09-12 11:47:16 GMT" - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } + "xAxis" : { + "type" : "category" }, - "title" : { - "text" : "Perl Weekly Challenge Language" + "subtitle" : { + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2020-09-12 19:18:11 GMT" }, - "chart" : { - "type" : "column" + "legend" : { + "enabled" : "false" }, "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" }, - "xAxis" : { - "type" : "category" - }, "plotOptions" : { "series" : { "borderWidth" : 0, "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" + "format" : "{point.y}", + "enabled" : 1 } } }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, "drilldown" : { "series" : [ { + "id" : "001", + "name" : "001", "data" : [ [ "Perl", @@ -46,11 +45,10 @@ "Blog", 11 ] - ], - "id" : "001", - "name" : "001" + ] }, { + "name" : "002", "data" : [ [ "Perl", @@ -65,10 +63,10 @@ 10 ] ], - "id" : "002", - "name" : "002" + "id" : "002" }, { + "id" : "003", "data" : [ [ "Perl", @@ -83,7 +81,6 @@ 9 ] ], - "id" : "003", "name" : "003" }, { @@ -101,11 +98,12 @@ 10 ] ], - "id" : "004", - "name" : "004" + "name" : "004", + "id" : "004" }, { "id" : "005", + "name" : "005", "data" : [ [ "Perl", @@ -119,10 +117,10 @@ "Blog", 12 ] - ], - "name" : "005" + ] }, { + "id" : "006", "data" : [ [ "Perl", @@ -137,12 +135,10 @@ 7 ] ], - "id" : "006", "name" : "006" }, { "name" : "007", - "id" : "007", "data" : [ [ "Perl", @@ -156,10 +152,11 @@ "Blog", 10 ] - ] + ], + "id" : "007" }, { - "id" : "008", + "name" : "008", "data" : [ [ "Perl", @@ -174,9 +171,10 @@ 12 ] ], - "name" : "008" + "id" : "008" }, { + "id" : "009", "name" : "009", "data" : [ [ @@ -191,10 +189,10 @@ "Blog", 13 ] - ], - "id" : "009" + ] }, { + "id" : "010", "data" : [ [ "Perl", @@ -209,10 +207,11 @@ 11 ] ], - "id" : "010", "name" : "010" }, { + "id" : "011", + "name" : "011", "data" : [ [ "Perl", @@ -226,12 +225,11 @@ "Blog", 10 ] - ], - "id" : "011", - "name" : "011" + ] }, { "id" : "012", + "name" : "012", "data" : [ [ "Perl", @@ -245,10 +243,10 @@ "Blog", 11 ] - ], - "name" : "012" + ] }, { + "name" : "013", "data" : [ [ "Perl", @@ -263,11 +261,10 @@ 13 ] ], - "id" : "013", - "name" : "013" + "id" : "013" }, { - "id" : "014", + "name" : "014", "data" : [ [ "Perl", @@ -282,9 +279,11 @@ 15 ] ], - "name" : "014" + "id" : "014" }, { + "id" : "015", + "name" : "015", "data" : [ [ "Perl", @@ -298,11 +297,11 @@ "Blog", 15 ] - ], - "id" : "015", - "name" : "015" + ] }, { + "id" : "016", + "name" : "016", "data" : [ [ "Perl", @@ -316,12 +315,9 @@ "Blog", 12 ] - ], - "id" : "016", - "name" : "016" + ] }, { - "name" : "017", "id" : "017", "data" : [ [ @@ -336,10 +332,10 @@ "Blog", 12 ] - ] + ], + "name" : "017" }, { - "id" : "018", "data" : [ [ "Perl", @@ -354,7 +350,8 @@ 14 ] ], - "name" : "018" + "name" : "018", + "id" : "018" }, { "id" : "019", @@ -375,6 +372,8 @@ "name" : "019" }, { + "id" : "020", + "name" : "020", "data" : [ [ "Perl", @@ -388,11 +387,10 @@ "Blog", 13 ] - ], - "id" : "020", - "name" : "020" + ] }, { + "id" : "021", "data" : [ [ "Perl", @@ -407,10 +405,11 @@ 10 ] ], - "id" : "021", "name" : "021" }, { + "id" : "022", + "name" : "022", "data" : [ [ "Perl", @@ -424,12 +423,9 @@ "Blog", 10 ] - ], - "id" : "022", - "name" : "022" + ] }, { - "name" : "023", "id" : "023", "data" : [ [ @@ -444,10 +440,12 @@ "Blog", 12 ] - ] + ], + "name" : "023" }, { "id" : "024", + "name" : "024", "data" : [ [ "Perl", @@ -461,11 +459,10 @@ "Blog", 11 ] - ], - "name" : "024" + ] }, { - "id" : "025", + "name" : "025", "data" : [ [ "Perl", @@ -480,9 +477,10 @@ 12 ] ], - "name" : "025" + "id" : "025" }, { + "name" : "026", "data" : [ [ "Perl", @@ -497,10 +495,10 @@ 10 ] ], - "id" : "026", - "name" : "026" + "id" : "026" }, { + "name" : "027", "data" : [ [ "Perl", @@ -515,10 +513,11 @@ 9 ] ], - "id" : "027", - "name" : "027" + "id" : "027" }, { + "id" : "028", + "name" : "028", "data" : [ [ "Perl", |
