diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-05-03 02:29:06 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-05-03 02:29:06 +0100 |
| commit | a573cfbacef563789fe754bbaed7595ed8133394 (patch) | |
| tree | cd9c51a79c1311e97434c5ba0f583659016e5434 | |
| parent | bd3470a0b6a23e9a759f3991eba1a6c86e59c58e (diff) | |
| download | perlweeklychallenge-club-a573cfbacef563789fe754bbaed7595ed8133394.tar.gz perlweeklychallenge-club-a573cfbacef563789fe754bbaed7595ed8133394.tar.bz2 perlweeklychallenge-club-a573cfbacef563789fe754bbaed7595ed8133394.zip | |
- Added solutions by Pete Houston.
| -rw-r--r-- | challenge-110/pete-houston/perl/ch-1.pl | 91 | ||||
| -rw-r--r-- | challenge-110/pete-houston/perl/ch-2.pl | 32 | ||||
| -rw-r--r-- | stats/pwc-current.json | 441 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 68 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 1560 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 746 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 100 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 34 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 46 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 102 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 54 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 108 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 32 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 480 |
15 files changed, 2036 insertions, 1898 deletions
diff --git a/challenge-110/pete-houston/perl/ch-1.pl b/challenge-110/pete-houston/perl/ch-1.pl new file mode 100644 index 0000000000..0bba75e207 --- /dev/null +++ b/challenge-110/pete-houston/perl/ch-1.pl @@ -0,0 +1,91 @@ +#!/usr/bin/env perl +#=============================================================================== +# +# FILE: 11001.pl +# +# USAGE: ./11001.pl < file_of_nums.txt +# +# DESCRIPTION: Echo only valid phone numbers +# +# NOTES: See POD for interpretation of the task +# AUTHOR: Pete Houston (pete), cpan@openstrike.co.uk +# ORGANIZATION: Openstrike +# VERSION: 1.0 +# CREATED: 26/04/21 +#=============================================================================== + +use strict; +use warnings; + +=head1 Assumptions + +Given the description of the problem there are a number of assumptions +which must be made when constructing a solution. Everyone must address +these ambiguities whether consciously or otherwise. + +=over + +=item Whitespace + +In the definition of acceptable formats, the first format has a double +whitespace between the IDC and the remainder whereas the other formats +have a single whitespace there. In the sample inputs, none of the given +lines have a double whitespace and yet the outputs show lines which can +only match the first format. + +Possible conclusions are + +=over + +=item all whitespace is to be ignored + +=item all whitespace is to be collapsed + +=item the spec has a typo and only single whitespaces are valid + +=back + +The first of these seems unlikely as it would permit sufficiently large +whole numbers to be interpreted as phone numbers. + +The significance of multiple whitespaces is unknown in the data corpus +but given the standard approach of being liberal in what one accpets +and strict in what one produces it would be reasonable to think that +collapsing sounds like the best compromise. Along similar lines I will +also collapse any whitespace that matches C<\s>. + +There is also the matter of leading whitespace in the output. One line +of output (with the 3-character IDC) has a leading space. We assume that +this fomatting is required. + +=item Multiple numbers per line + +We are told nothing about the input file. The sample input has 1 +possible valid entry per line but can we assume this for all input +files? + +As we are asked to display the numbers, not the lines then let us cater +for the possibility that there may be any number of matches on any given +line. + +=back + +=cut + +# Slurp +undef $/; +my $in = <STDIN>; + +# Match +my @valid = $in =~ /(?:\+\d\d|\(\d\d\)|\d{4})\s+\d{10}/g; + +# Normalise +for (@valid) { + # Collapse multiple whitespace, convert tabs and newlines + s/\s+/ /g; + # Leading whitespace for +nn + s/^\+/ +/; +} + +# Output +print join ("\n", @valid), "\n"; diff --git a/challenge-110/pete-houston/perl/ch-2.pl b/challenge-110/pete-houston/perl/ch-2.pl new file mode 100644 index 0000000000..dbfc5c991f --- /dev/null +++ b/challenge-110/pete-houston/perl/ch-2.pl @@ -0,0 +1,32 @@ +#!/usr/bin/env perl +#=============================================================================== +# +# FILE: 11002.pl +# +# USAGE: ./11002.pl INFILE OUTFILE [ INENC [ OUTENC ]] +# +# DESCRIPTION: Transpose the given CSV file, writing results to the +# given output file. +# +# OPTIONS: Unless provided, the input file encoding defaults to UTF-8. +# Unless provided, the output file encoding defaults to +# the same as the input file encoding. +# REQUIREMENTS: Array::Transpose, Text::CSV, Perl 5.10 or newer +# AUTHOR: Pete Houston (pete), cpan@openstrike.co.uk +# ORGANIZATION: Openstrike +# VERSION: 1.0 +# CREATED: 26/04/21 +#=============================================================================== + +use strict; +use warnings; +use 5.010; +use Array::Transpose; +use Text::CSV 1.90 'csv'; + +my $enc_in = $ARGV[2] // 'UTF-8'; +my $enc_out = $ARGV[3] // $enc_in; +my $array = csv (in => $ARGV[0], encoding => $enc_in); +my @tr = transpose ($array); + +csv (in => \@tr, out => $ARGV[1], encoding => $enc_out); diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 132c1150f2..9cd2a9a952 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,7 +1,181 @@ { + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, + "chart" : { + "type" : "column" + }, + "title" : { + "text" : "Perl Weekly Challenge - 110" + }, + "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/>" + }, + "legend" : { + "enabled" : 0 + }, + "subtitle" : { + "text" : "[Champions: 26] Last updated at 2021-05-03 01:27:38 GMT" + }, + "xAxis" : { + "type" : "category" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "series" : [ + { + "name" : "Perl Weekly Challenge - 110", + "colorByPoint" : 1, + "data" : [ + { + "y" : 3, + "name" : "Aaron Smith", + "drilldown" : "Aaron Smith" + }, + { + "y" : 2, + "name" : "Abigail", + "drilldown" : "Abigail" + }, + { + "y" : 4, + "name" : "Andinus", + "drilldown" : "Andinus" + }, + { + "y" : 4, + "drilldown" : "Athanasius", + "name" : "Athanasius" + }, + { + "y" : 2, + "drilldown" : "Cheok-Yin Fung", + "name" : "Cheok-Yin Fung" + }, + { + "name" : "Colin Crain", + "drilldown" : "Colin Crain", + "y" : 5 + }, + { + "name" : "Cristina Heredia", + "drilldown" : "Cristina Heredia", + "y" : 1 + }, + { + "y" : 3, + "name" : "Dave Jacoby", + "drilldown" : "Dave Jacoby" + }, + { + "y" : 4, + "drilldown" : "Flavio Poletti", + "name" : "Flavio Poletti" + }, + { + "drilldown" : "James Smith", + "name" : "James Smith", + "y" : 3 + }, + { + "drilldown" : "Jan Krnavek", + "name" : "Jan Krnavek", + "y" : 2 + }, + { + "y" : 2, + "name" : "Joan Mimosinnet", + "drilldown" : "Joan Mimosinnet" + }, + { + "name" : "Jorg Sommrey", + "drilldown" : "Jorg Sommrey", + "y" : 2 + }, + { + "y" : 5, + "name" : "Laurent Rosenfeld", + "drilldown" : "Laurent Rosenfeld" + }, + { + "y" : 4, + "drilldown" : "Luca Ferrari", + "name" : "Luca Ferrari" + }, + { + "name" : "Mark Anderson", + "drilldown" : "Mark Anderson", + "y" : 2 + }, + { + "drilldown" : "Mohammad S Anwar", + "name" : "Mohammad S Anwar", + "y" : 4 + }, + { + "y" : 2, + "drilldown" : "Niels van Dijke", + "name" : "Niels van Dijke" + }, + { + "drilldown" : "Pete Houston", + "name" : "Pete Houston", + "y" : 2 + }, + { + "y" : 5, + "drilldown" : "Roger Bell_West", + "name" : "Roger Bell_West" + }, + { + "drilldown" : "Ryan Thompson", + "name" : "Ryan Thompson", + "y" : 4 + }, + { + "name" : "Simon Green", + "drilldown" : "Simon Green", + "y" : 3 + }, + { + "name" : "Stuart Little", + "drilldown" : "Stuart Little", + "y" : 4 + }, + { + "y" : 4, + "name" : "Ulrich Rieke", + "drilldown" : "Ulrich Rieke" + }, + { + "drilldown" : "W. Luis Mochan", + "name" : "W. Luis Mochan", + "y" : 3 + }, + { + "y" : 2, + "name" : "Wanderdoc", + "drilldown" : "Wanderdoc" + } + ] + } + ], "drilldown" : { "series" : [ { + "name" : "Aaron Smith", + "id" : "Aaron Smith", "data" : [ [ "Raku", @@ -11,23 +185,19 @@ "Blog", 1 ] - ], - "id" : "Aaron Smith", - "name" : "Aaron Smith" + ] }, { + "name" : "Abigail", "data" : [ [ "Perl", 2 ] ], - "id" : "Abigail", - "name" : "Abigail" + "id" : "Abigail" }, { - "id" : "Andinus", - "name" : "Andinus", "data" : [ [ "Raku", @@ -37,11 +207,11 @@ "Blog", 2 ] - ] + ], + "id" : "Andinus", + "name" : "Andinus" }, { - "name" : "Athanasius", - "id" : "Athanasius", "data" : [ [ "Perl", @@ -51,19 +221,22 @@ "Raku", 2 ] - ] + ], + "id" : "Athanasius", + "name" : "Athanasius" }, { + "name" : "Cheok-Yin Fung", "data" : [ [ "Perl", 2 ] ], - "id" : "Cheok-Yin Fung", - "name" : "Cheok-Yin Fung" + "id" : "Cheok-Yin Fung" }, { + "id" : "Colin Crain", "data" : [ [ "Perl", @@ -78,20 +251,21 @@ 1 ] ], - "name" : "Colin Crain", - "id" : "Colin Crain" + "name" : "Colin Crain" }, { - "name" : "Cristina Heredia", - "id" : "Cristina Heredia", "data" : [ [ "Perl", 1 ] - ] + ], + "id" : "Cristina Heredia", + "name" : "Cristina Heredia" }, { + "name" : "Dave Jacoby", + "id" : "Dave Jacoby", "data" : [ [ "Perl", @@ -101,9 +275,7 @@ "Blog", 1 ] - ], - "id" : "Dave Jacoby", - "name" : "Dave Jacoby" + ] }, { "data" : [ @@ -116,10 +288,11 @@ 2 ] ], - "name" : "Flavio Poletti", - "id" : "Flavio Poletti" + "id" : "Flavio Poletti", + "name" : "Flavio Poletti" }, { + "name" : "James Smith", "data" : [ [ "Perl", @@ -130,22 +303,21 @@ 1 ] ], - "id" : "James Smith", - "name" : "James Smith" + "id" : "James Smith" }, { "name" : "Jan Krnavek", - "id" : "Jan Krnavek", "data" : [ [ "Raku", 2 ] - ] + ], + "id" : "Jan Krnavek" }, { - "id" : "Joan Mimosinnet", "name" : "Joan Mimosinnet", + "id" : "Joan Mimosinnet", "data" : [ [ "Raku", @@ -154,13 +326,13 @@ ] }, { + "name" : "Jorg Sommrey", "data" : [ [ "Perl", 2 ] ], - "name" : "Jorg Sommrey", "id" : "Jorg Sommrey" }, { @@ -196,16 +368,17 @@ "name" : "Luca Ferrari" }, { + "name" : "Mark Anderson", "data" : [ [ "Raku", 2 ] ], - "name" : "Mark Anderson", "id" : "Mark Anderson" }, { + "name" : "Mohammad S Anwar", "data" : [ [ "Perl", @@ -216,12 +389,21 @@ 2 ] ], - "id" : "Mohammad S Anwar", - "name" : "Mohammad S Anwar" + "id" : "Mohammad S Anwar" }, { "name" : "Niels van Dijke", - "id" : "Niels van Dijke", + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Niels van Dijke" + }, + { + "name" : "Pete Houston", + "id" : "Pete Houston", "data" : [ [ "Perl", @@ -231,7 +413,6 @@ }, { "id" : "Roger Bell_West", - "name" : "Roger Bell_West", "data" : [ [ "Perl", @@ -245,7 +426,8 @@ "Blog", 1 ] - ] + ], + "name" : "Roger Bell_West" }, { "name" : "Ryan Thompson", @@ -262,6 +444,7 @@ ] }, { + "id" : "Simon Green", "data" : [ [ "Perl", @@ -272,10 +455,11 @@ 1 ] ], - "name" : "Simon Green", - "id" : "Simon Green" + "name" : "Simon Green" }, { + "name" : "Stuart Little", + "id" : "Stuart Little", "data" : [ [ "Perl", @@ -285,11 +469,10 @@ "Raku", 2 ] - ], - "name" : "Stuart Little", - "id" : "Stuart Little" + ] }, { + "name" : "Ulrich Rieke", "data" : [ [ "Perl", @@ -300,10 +483,11 @@ 2 ] ], - "id" : "Ulrich Rieke", - "name" : "Ulrich Rieke" + "id" : "Ulrich Rieke" }, { + "name" : "W. Luis Mochan", + "id" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -313,187 +497,18 @@ "Blog", 1 ] - ], - "name" : "W. Luis Mochan", - "id" : "W. Luis Mochan" + ] }, { + "name" : "Wanderdoc", "data" : [ [ "Perl", 2 ] ], - "name" : "Wanderdoc", "id" : "Wanderdoc" } ] - }, - "chart" : { - "type" : "column" - }, - "subtitle" : { - "text" : "[Champions: 25] Last updated at 2021-05-02 21:14:14 GMT" - }, - "plotOptions" : { - "series" : { - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 - } - }, - "tooltip" : { - "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", - "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", - "followPointer" : 1 - }, - "title" : { - "text" : "Perl Weekly Challenge - 110" - }, - "series" : [ - { - "colorByPoint" : 1, - "name" : "Perl Weekly Challenge - 110", - "data" : [ - { - "name" : "Aaron Smith", - "y" : 3, - "drilldown" : "Aaron Smith" - }, - { - "name" : "Abigail", - "y" : 2, - "drilldown" : "Abigail" - }, - { - "y" : 4, - "drilldown" : "Andinus", - "name" : "Andinus" - }, - { - "drilldown" : "Athanasius", - "y" : 4, - "name" : "Athanasius" - }, - { - "name" : "Cheok-Yin Fung", - "drilldown" : "Cheok-Yin Fung", - "y" : 2 - }, - { - "y" : 5, - "drilldown" : "Colin Crain", - "name" : "Colin Crain" - }, - { - "y" : 1, - "drilldown" : "Cristina Heredia", - "name" : "Cristina Heredia" - }, - { - "name" : "Dave Jacoby", - "drilldown" : "Dave Jacoby", - "y" : 3 - }, - { - "name" : "Flavio Poletti", - "drilldown" : "Flavio Poletti", - "y" : 4 - }, - { - "y" : 3, - "drilldown" : "James Smith", - "name" : "James Smith" - }, - { - "y" : 2, - "drilldown" : "Jan Krnavek", - "name" : "Jan Krnavek" - }, - { - "name" : "Joan Mimosinnet", - "y" : 2, - "drilldown" : "Joan Mimosinnet" - }, - { - "drilldown" : "Jorg Sommrey", - "y" : 2, - "name" : "Jorg Sommrey" - }, - { - "name" : "Laurent Rosenfeld", - "y" : 5, - "drilldown" : "Laurent Rosenfeld" - }, - { - "drilldown" : "Luca Ferrari", - "y" : 4, - "name" : "Luca Ferrari" - }, - { - "y" : 2, - "drilldown" : "Mark Anderson", - "name" : "Mark Anderson" - }, - { - "name" : "Mohammad S Anwar", - "y" : 4, - "drilldown" : "Mohammad S Anwar" - }, - { - "name" : "Niels van Dijke", - "y" : 2, - "drilldown" : "Niels van Dijke" - }, - { - "drilldown" : "Roger Bell_West", - "y" : 5, - "name" : "Roger Bell_West" - }, - { - "drilldown" : "Ryan Thompson", - "y" : 4, - "name" : "Ryan Thompson" - }, - { - "drilldown" : "Simon Green", - "y" : 3, - "name" : "Simon Green" - }, - { - "drilldown" : "Stuart Little", - "y" : 4, - "name" : "Stuart Little" - }, - { - "name" : "Ulrich Rieke", - "y" : 4, - "drilldown" : "Ulrich Rieke" - }, - { - "drilldown" : "W. Luis Mochan", - "y" : 3, - "name" : "W. Luis Mochan" - }, - { - "y" : 2, - "drilldown" : "Wanderdoc", - "name" : "Wanderdoc" - } - ] - } - ], - "xAxis" : { - "type" : "category" - }, - "legend" : { - "enabled" : 0 - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 2d1c87cf1a..2c5f3a7a92 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,6 +1,6 @@ { - "legend" : { - "enabled" : "false" + "subtitle" : { + "text" : "Last updated at 2021-05-03 01:27:38 GMT" }, "yAxis" : { "title" : { @@ -8,23 +8,21 @@ }, "min" : 0 }, - "subtitle" : { - "text" : "Last updated at 2021-05-02 21:14:14 GMT" - }, - "chart" : { - "type" : "column" - }, - "xAxis" : { - "type" : "category", - "labels" : { - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - } - } - }, "series" : [ { + "name" : "Contributions", + "dataLabels" : { + "enabled" : "true", + "align" : "right", + "format" : "{point.y:.0f}", + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + }, + "y" : 10, + "color" : "#FFFFFF", + "rotation" : -90 + }, "data" : [ [ "Blog", @@ -32,32 +30,34 @@ ], [ "Perl", - 5200 + 5202 ], [ "Raku", 3306 ] - ], - "name" : "Contributions", - "dataLabels" : { - "format" : "{point.y:.0f}", - "enabled" : "true", - "y" : 10, - "align" : "right", - "color" : "#FFFFFF", - "rotation" : -90, - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - } - } + ] } ], - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" + "xAxis" : { + "type" : "category", + "labels" : { + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + } + } + }, + "chart" : { + "type" : "column" }, "title" : { "text" : "Perl Weekly Challenge Contributions [2019 - 2020]" + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "legend" : { + "enabled" : "false" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 18621273c1..cf45c18153 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,9 +1,569 @@ { + "subtitle" : { + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2021-05-03 01:27:38 GMT" + }, + "series" : [ + { + "name" : "Perl Weekly Challenge Languages", + "data" : [ + { + "drilldown" : "001", + "name" : "#001", + "y" : 161 + }, + { + "name" : "#002", + "drilldown" : "002", + "y" : 125 + }, + { + "name" : "#003", + "drilldown" : "003", + "y" : 81 + }, + { + "y" : 99, + "drilldown" : "004", + "name" : "#004" + }, + { + "name" : "#005", + "drilldown" : "005", + "y" : 78 + }, + { + "y" : 58, + "drilldown" : "006", + "name" : "#006" + }, + { + "drilldown" : "007", + "name" : "#007", + "y" : 64 + }, + { + "y" : 78, + "name" : "#008", + "drilldown" : "008" + }, + { + "y" : 76, + "name" : "#009", + "drilldown" : "009" + }, + { + "y" : 65, + "drilldown" : "010", + "name" : "#010" + }, + { + "y" : 85, + "drilldown" : "011", + "name" : "#011" + }, + { + "y" : 89, + "drilldown" : "012", + "name" : "#012" + }, + { + "name" : "#013", + "drilldown" : "013", + "y" : 84 + }, + { + "drilldown" : "014", + "name" : "#014", + "y" : 101 + }, + { + "y" : 99, + "drilldown" : "015", + "name" : "#015" + }, + { + "y" : 70, + "name" : "#016", + "drilldown" : "016" + }, + { + "name" : "#017", + "drilldown" : "017", + "y" : 83 + }, + { + "drilldown" : "018", + "name" : "#018", + "y" : 80 + }, + { + "y" : 101, + "name" : "#019", + "drilldown" : "019" + }, + { + "drilldown" : "020", + "name" : "#020", + "y" : 99 + }, + { + "name" : "#021", + "drilldown" : "021", + "y" : 71 + }, + { + "name" : "#022", + "drilldown" : "022", + "y" : 67 + }, + { + "drilldown" : "023", + "name" : "#023", + "y" : 95 + }, + { + "drilldown" : "024", + "name" : "#024", + "y" : 74 + }, + { + "y" : 59, + "name" : "#025", + "drilldown" : "025" + }, + { + "drilldown" : "026", + "name" : "#026", + "y" : 74 + }, + { + "name" : "#027", + "drilldown" : "027", + "y" : 60 + }, + { + "y" : 80, + "drilldown" : "028", + "name" : "#028" + }, + { + "name" : "#029", + "drilldown" : "029", + "y" : 79 + }, + { + "name" : "#030", + "drilldown" : "030", + "y" : 117 + }, + { + "drilldown" : "031", + "name" : "#031", + "y" : 89 + }, + { + "name" : "#032", + "drilldown" : "032", + "y" : 94 + }, + { + "y" : 110, + "drilldown" : "033", + "name" : "#033" + }, + { + "drilldown" : "034", + "name" : "#034", + "y" : 64 |
