diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-11-28 17:22:25 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-11-28 17:22:25 +0000 |
| commit | d4bac3210ac8f55a72fe620f1e302805f0a4edbe (patch) | |
| tree | ce4cc4ef9f207cdbd67e778a83e7bc35c748bdc2 | |
| parent | 35abfbc65e8a074732d4296db747d464fb0775fe (diff) | |
| download | perlweeklychallenge-club-d4bac3210ac8f55a72fe620f1e302805f0a4edbe.tar.gz perlweeklychallenge-club-d4bac3210ac8f55a72fe620f1e302805f0a4edbe.tar.bz2 perlweeklychallenge-club-d4bac3210ac8f55a72fe620f1e302805f0a4edbe.zip | |
- Added solutions by Pete Houston.
| -rwxr-xr-x | challenge-140/pete-houston/awk/ch-2.awk | 30 | ||||
| -rwxr-xr-x | challenge-140/pete-houston/perl/ch-1.pl | 62 | ||||
| -rwxr-xr-x | challenge-140/pete-houston/perl/ch-2.pl | 31 | ||||
| -rw-r--r-- | stats/pwc-current.json | 425 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 80 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 1934 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 384 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 36 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 38 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 44 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 108 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 116 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 36 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 98 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 38 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 50 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 532 |
17 files changed, 2090 insertions, 1952 deletions
diff --git a/challenge-140/pete-houston/awk/ch-2.awk b/challenge-140/pete-houston/awk/ch-2.awk new file mode 100755 index 0000000000..5a4bfa56ae --- /dev/null +++ b/challenge-140/pete-houston/awk/ch-2.awk @@ -0,0 +1,30 @@ +#!/usr/bin/gawk -f
+#===============================================================================
+#
+# FILE: 14002.awk
+#
+# USAGE: ./14002.awk [ INFILE ]
+#
+# DESCRIPTION: Print the Kth element of the sorted multiplication table
+# of I and J. Provide input of J, J and K on each line of
+# INFILE or STDIN.
+#
+# REQUIREMENTS: Requires asort which is a gawkism so standard awk will
+# likely not work.
+# AUTHOR: Pete Houston (pete), cpan@openstrike.co.uk
+# ORGANIZATION: Openstrike
+# VERSION: 1.0
+# CREATED: 22/11/21
+#===============================================================================
+
+{
+ n = 0
+ for (x = 1; x <= $1; x++) {
+ for (y = 1; y <= $2; y++) {
+ prods[n++] = x * y
+ }
+ }
+ asort (prods)
+ print prods[$3]
+ delete prods
+}
diff --git a/challenge-140/pete-houston/perl/ch-1.pl b/challenge-140/pete-houston/perl/ch-1.pl new file mode 100755 index 0000000000..3d38800f1b --- /dev/null +++ b/challenge-140/pete-houston/perl/ch-1.pl @@ -0,0 +1,62 @@ +#!/usr/bin/env perl +#=============================================================================== +# +# FILE: 14001.pl +# +# USAGE: ./14001.pl X Y +# +# DESCRIPTION: Add the two binary numbers and print the result. eg: +# +# $ ./14001.pl 1101 111 +# 10100 +# +# AUTHOR: Pete Houston (pete), cpan@openstrike.co.uk +# ORGANIZATION: Openstrike +# VERSION: 1.0 +# CREATED: 22/11/21 +#=============================================================================== + +use strict; +use warnings; + +package Bin; + +use overload ( + '+' => 'add', + '""' => 'bin' +); + +sub new { + my ($class, $str) = @_; + # $str is a string of bits, eg: "10010"; + my $self = { + bin => $str, + dec => defined ($str) ? bin2dec ($str) : $str + }; + bless $self, $class; +} + +sub dec { $_[0]->{dec} }; +sub bin { $_[0]->{bin} }; + +sub bin2dec { + my @bits = split //, shift; + my $dec = 0; + my $fac = 1; + while (@bits) { + $_ = pop @bits; + $dec += $fac * $_; + $fac *= 2; + } + return $dec; +} + +sub add { + my ($x, $y) = @_; + my $dsum = $x->{dec} + $y->{dec}; + return Bin->new (sprintf "%b", $dsum); +} + +package main; + +print Bin->new ($ARGV[0]) + Bin->new ($ARGV[1]) . "\n"; diff --git a/challenge-140/pete-houston/perl/ch-2.pl b/challenge-140/pete-houston/perl/ch-2.pl new file mode 100755 index 0000000000..e1eab6035e --- /dev/null +++ b/challenge-140/pete-houston/perl/ch-2.pl @@ -0,0 +1,31 @@ +#!/usr/bin/env perl +#=============================================================================== +# +# FILE: 14002.pl +# +# USAGE: ./14002.pl I J K +# +# DESCRIPTION: Print the Kth element of the sorted multiplication table +# of I and J. +# +# AUTHOR: Pete Houston (pete), cpan@openstrike.co.uk +# ORGANIZATION: Openstrike +# VERSION: 1.0 +# CREATED: 22/11/21 +#=============================================================================== + +use strict; +use warnings; + +my ($i, $j, $k) = @ARGV; +die "$k is greater than $i * $j\n" if $k > $i * $j; + +my @prods; +for my $x (1 .. $i) { + for my $y (1 .. $j) { + push @prods, $x * $y; + } +} + +@prods = sort { $a <=> $b } @prods; +print $prods[$k - 1] . "\n"; diff --git a/stats/pwc-current.json b/stats/pwc-current.json index af01562a84..943a2779a1 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,155 +1,4 @@ { - "series" : [ - { - "name" : "The Weekly Challenge - 140", - "data" : [ - { - "y" : 2, - "drilldown" : "Abigail", - "name" : "Abigail" - }, - { - "y" : 2, - "drilldown" : "Alexander Pankoff", - "name" : "Alexander Pankoff" - }, - { - "drilldown" : "Andrew Shitov", - "name" : "Andrew Shitov", - "y" : 2 - }, - { - "y" : 4, - "name" : "Athanasius", - "drilldown" : "Athanasius" - }, - { - "name" : "Cheok-Yin Fung", - "drilldown" : "Cheok-Yin Fung", - "y" : 1 - }, - { - "drilldown" : "Cristina Heredia", - "name" : "Cristina Heredia", - "y" : 1 - }, - { - "y" : 3, - "drilldown" : "Dave Jacoby", - "name" : "Dave Jacoby" - }, - { - "name" : "E. Choroba", - "drilldown" : "E. Choroba", - "y" : 2 - }, - { - "drilldown" : "Feng Chang", - "name" : "Feng Chang", - "y" : 2 - }, - { - "drilldown" : "Jake", - "name" : "Jake", - "y" : 2 - }, - { - "name" : "James Smith", - "drilldown" : "James Smith", - "y" : 3 - }, - { - "y" : 2, - "drilldown" : "Jan Krnavek", - "name" : "Jan Krnavek" - }, - { - "y" : 2, - "name" : "Jorg Sommrey", - "drilldown" : "Jorg Sommrey" - }, - { - "y" : 3, - "drilldown" : "Laurent Rosenfeld", - "name" : "Laurent Rosenfeld" - }, - { - "drilldown" : "Lubos Kolouch", - "name" : "Lubos Kolouch", - "y" : 2 - }, - { - "drilldown" : "Luca Ferrari", - "name" : "Luca Ferrari", - "y" : 6 - }, - { - "y" : 1, - "drilldown" : "Mano Chandar", - "name" : "Mano Chandar" - }, - { - "y" : 1, - "name" : "Olivier Delouya", - "drilldown" : "Olivier Delouya" - }, - { - "name" : "Paul Fajman", - "drilldown" : "Paul Fajman", - "y" : 1 - }, - { - "name" : "Paulo Custodio", - "drilldown" : "Paulo Custodio", - "y" : 2 - }, - { - "name" : "Peter Campbell Smith", - "drilldown" : "Peter Campbell Smith", - "y" : 2 - }, - { - "y" : 1, - "drilldown" : "Robert DiCicco", - "name" : "Robert DiCicco" - }, - { - "y" : 5, - "name" : "Roger Bell_West", - "drilldown" : "Roger Bell_West" - }, - { - "name" : "Simon Green", - "drilldown" : "Simon Green", - "y" : 3 - }, - { - "y" : 3, - "drilldown" : "Ulrich Rieke", - "name" : "Ulrich Rieke" - }, - { - "y" : 3, - "drilldown" : "W. Luis Mochan", - "name" : "W. Luis Mochan" - }, - { - "name" : "Wanderdoc", - "drilldown" : "Wanderdoc", - "y" : 2 - } - ], - "colorByPoint" : 1 - } - ], - "tooltip" : { - "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/>", - "followPointer" : 1 - }, - "chart" : { - "type" : "column" - }, "plotOptions" : { "series" : { "dataLabels" : { @@ -159,40 +8,34 @@ "borderWidth" : 0 } }, - "title" : { - "text" : "The Weekly Challenge - 140" - }, - "legend" : { - "enabled" : 0 - }, "xAxis" : { "type" : "category" }, "drilldown" : { "series" : [ { + "name" : "Abigail", + "id" : "Abigail", "data" : [ [ "Perl", 2 ] - ], - "name" : "Abigail", - "id" : "Abigail" + ] }, { - "id" : "Alexander Pankoff", "name" : "Alexander Pankoff", "data" : [ [ "Perl", 2 ] - ] + ], + "id" : "Alexander Pankoff" }, { - "id" : "Andrew Shitov", "name" : "Andrew Shitov", + "id" : "Andrew Shitov", "data" : [ [ "Raku", @@ -201,7 +44,7 @@ ] }, { - "id" : "Athanasius", + "name" : "Athanasius", "data" : [ [ "Perl", @@ -212,11 +55,11 @@ 2 ] ], - "name" : "Athanasius" + "id" : "Athanasius" }, { - "id" : "Cheok-Yin Fung", "name" : "Cheok-Yin Fung", + "id" : "Cheok-Yin Fung", "data" : [ [ "Perl", @@ -225,8 +68,8 @@ ] }, { - "id" : "Cristina Heredia", "name" : "Cristina Heredia", + "id" : "Cristina Heredia", "data" : [ [ "Perl", @@ -235,7 +78,6 @@ ] }, { - "id" : "Dave Jacoby", "data" : [ [ "Perl", @@ -246,17 +88,18 @@ 1 ] ], + "id" : "Dave Jacoby", "name" : "Dave Jacoby" }, { "id" : "E. Choroba", - "name" : "E. Choroba", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "E. Choroba" }, { "id" : "Feng Chang", @@ -269,17 +112,17 @@ "name" : "Feng Chang" }, { - "id" : "Jake", "data" : [ [ "Perl", 2 ] ], + "id" : "Jake", "name" : "Jake" }, { - "id" : "James Smith", + "name" : "James Smith", "data" : [ [ "Perl", @@ -290,30 +133,30 @@ 1 ] ], - "name" : "James Smith" + "id" : "James Smith" }, { - "id" : "Jan Krnavek", "name" : "Jan Krnavek", "data" : [ [ "Blog", 2 ] - ] + ], + "id" : "Jan Krnavek" }, { + "name" : "Jorg Sommrey", + "id" : "Jorg Sommrey", "data" : [ [ "Perl", 2 ] - ], - "name" : "Jorg Sommrey", - "id" : "Jorg Sommrey" + ] }, { - "name" : "Laurent Rosenfeld", + "id" : "Laurent Rosenfeld", "data" : [ [ "Perl", @@ -328,19 +171,21 @@ 1 ] ], - "id" : "Laurent Rosenfeld" + "name" : "Laurent Rosenfeld" }, { - "id" : "Lubos Kolouch", "data" : [ [ "Perl", 2 ] ], + "id" : "Lubos Kolouch", "name" : "Lubos Kolouch" }, { + "name" : "Luca Ferrari", + "id" : "Luca Ferrari", "data" : [ [ "Raku", @@ -350,39 +195,37 @@ "Blog", 4 ] - ], - "name" : "Luca Ferrari", - "id" : "Luca Ferrari" + ] }, { + "name" : "Mano Chandar", "id" : "Mano Chandar", "data" : [ [ "Perl", 1 ] - ], - "name" : "Mano Chandar" + ] }, { + "id" : "Olivier Delouya", "data" : [ [ "Perl", 1 ] ], - "name" : "Olivier Delouya", - "id" : "Olivier Delouya" + "name" : "Olivier Delouya" }, { - "name" : "Paul Fajman", + "id" : "Paul Fajman", "data" : [ [ "Perl", 1 ] ], - "id" : "Paul Fajman" + "name" : "Paul Fajman" }, { "name" : "Paulo Custodio", @@ -395,24 +238,34 @@ "id" : "Paulo Custodio" }, { - "name" : "Peter Campbell Smith", + "id" : "Pete Houston", + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Pete Houston" + }, + { + "id" : "Peter Campbell Smith", "data" : [ [ "Perl", 2 ] ], - "id" : "Peter Campbell Smith" + "name" : "Peter Campbell Smith" }, { "id" : "Robert DiCicco", - "name" : "Robert DiCicco", "data" : [ [ "Perl", 1 ] - ] + ], + "name" : "Robert DiCicco" }, { "id" : "Roger Bell_West", @@ -433,6 +286,8 @@ "name" : "Roger Bell_West" }, { + "name" : "Simon Green", + "id" : "Simon Green", "data" : [ [ "Perl", @@ -442,11 +297,10 @@ "Blog", 1 ] - ], - "name" : "Simon Green", - "id" : "Simon Green" + ] }, { + "name" : "Ulrich Rieke", "id" : "Ulrich Rieke", "data" : [ [ @@ -457,11 +311,9 @@ "Raku", 2 ] - ], - "name" : "Ulrich Rieke" + ] }, { - "id" : "W. Luis Mochan", "name" : "W. Luis Mochan", "data" : [ [ @@ -472,26 +324,189 @@ "Blog", 1 ] - ] + ], + "id" : "W. Luis Mochan" }, { - "id" : "Wanderdoc", "data" : [ [ "Perl", 2 ] ], + "id" : "Wanderdoc", "name" : "Wanderdoc" } ] }, + "subtitle" : { + "text" : "[Champions: 28] Last updated at 2021-11-28 17:20:57 GMT" + }, + "chart" : { + "type" : "column" + }, + "tooltip" : { + "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/>", + "followPointer" : 1 + }, "yAxis" : { "title" : { "text" : "Total Solutions" } }, - "subtitle" : { - "text" : "[Champions: 27] Last updated at 2021-11-28 16:09:43 GMT" - } + "legend" : { + "enabled" : 0 + }, + "title" : { + "text" : "The Weekly Challenge - 140" + }, + "series" : [ + { + "colorByPoint" : 1, + "data" : [ + { + "y" : 2, + "name" : "Abigail", + "drilldown" : "Abigail" + }, + { + "drilldown" : "Alexander Pankoff", + "name" : "Alexander Pankoff", + "y" : 2 + }, + { + "y" : 2, + "drilldown" : "Andrew Shitov", + "name" : "Andrew Shitov" + }, + { + "y" : 4, + "name" : "Athanasius", + "drilldown" : "Athanasius" + }, + { + "name" : "Cheok-Yin Fung", + "drilldown" : "Cheok-Yin Fung", + "y" : 1 + }, + { + "name" : "Cristina Heredia", + "drilldown" : "Cristina Heredia", + "y" : 1 + }, + { + "drilldown" : "Dave Jacoby", + "name" : "Dave Jacoby", + "y" : 3 + }, + { + "drilldown" : "E. Choroba", + "name" : "E. Choroba", + "y" : 2 + }, + { + "drilldown" : "Feng Chang", + "name" : "Feng Chang", + "y" : 2 + }, + { + "name" : "Jake", + "drilldown" : "Jake", + "y" : 2 + }, + { + "name" : "James Smith", + "drilldown" : "James Smith", + "y" : 3 + }, + { + "y" : 2, + "drilldown" : "Jan Krnavek", + "name" : "Jan Krnavek" + }, + { + "name" : "Jorg Sommrey", + "drilldown" : "Jorg Sommrey", + "y" : 2 + }, + { + "name" : "Laurent Rosenfeld", + "drilldown" : "Laurent Rosenfeld", + "y" : 3 + }, + { + "y" : 2, + "name" : "Lubos Kolouch", + "drilldown" : "Lubos Kolouch" + }, + { + "name" : "Luca Ferrari", + "drilldown" : "Luca Ferrari", + "y" : 6 + }, + { + "y" : 1, + "name" : "Mano Chandar", + "drilldown" : "Mano Chandar" + }, + { + "y" : 1, + "drilldown" : "Olivier Delouya", + "name" : "Olivier Delouya" + }, + { + "y" : 1, + "name" : "Paul Fajman", + "drilldown" : "Paul Fajman" + }, + { + "drilldown" : "Paulo Custodio", + "name" : "Paulo Custodio", + "y" : 2 + }, + { + "y" : 2, + "name" : "Pete Houston", + "drilldown" : "Pete Houston" + }, + { + "name" : "Peter Campbell Smith", + "drilldown" : "Peter Campbell Smith", + "y" : 2 + }, + { + "drilldown" : "Robert DiCicco", + "name" : "Robert DiCicco", + "y" : 1 + }, + { + "drilldown" : "Roger Bell_West", + "name" : "Roger Bell_West", + "y" : 5 + }, + { + "y" : 3, + "drilldown" : "Simon Green", + "name" : "Simon Green" + }, + { + "y" : 3, + "name" : "Ulrich Rieke", + "drilldown" : "Ulrich Rieke" + }, + { + "name" : "W. Luis Mochan", + "drilldown" : "W. Luis Mochan", + "y" : 3 + }, + { + "y" : 2, + "drilldown" : "Wanderdoc", + "name" : "Wanderdoc" + } + ], + "name" : "The Weekly Challenge - 140" + } + ] } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 4f50e81352..c50c5aa698 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,46 +1,12 @@ { - "subtitle" : { - "text" : "Last updated at 2021-11-28 16:09:43 GMT" - }, - "yAxis" : { - "min" : 0, - "title" : { - "text" : null - } - }, - "xAxis" : { - "type" : "category", - "labels" : { - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - } - } - }, - "legend" : { - "enabled" : "false" - }, - "title" : { - "text" : "The Weekly Challenge Contributions [2019 - 2021]" + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" }, "chart" : { "type" : "column" }, "series" : [ { - "dataLabels" : { - "enabled" : "true", - "align" : "right", - "rotation" : -90, - "color" : "#FFFFFF", - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - }, - "y" : 10, - "format" : "{point.y:.0f}" - }, - "name" : "Contributions", "data" : [ [ "Blog", @@ -48,16 +14,50 @@ ], [ "Perl", - 6734 + 6736 ], [ "Raku", 4090 ] - ] + ], + "name" : "Contributions", + "dataLabels" : { + "color" : "#FFFFFF", + "y" : 10, + "align" : "right", + "rotation" : -90, + "format" : "{point.y:.0f}", + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + }, + "enabled" : "true" + } } ], - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" + "title" : { + "text" : "The Weekly Challenge Contributions [2019 - 2021]" + }, + "legend" : { + "enabled" : "false" + }, + "yAxis" : { + "title" : { + "text" : null + }, + "min" : 0 + }, + "subtitle" : { + "text" : "Last updated at 2021-11-28 17:20:57 GMT" + }, + "xAxis" : { + "type" : "category", + "labels" : { + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + } + } } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index cfa1724740..9fb5de934c 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,749 +1,8 @@ { - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2021-11-28 16:09:43 GMT" - }, - "series" : [ - { - "data" : [ - { - "name" : "#001", - "drilldown" : "001", - "y" : 161 - }, - { - "drilldown" : "002", - "name" : "#002", - "y" : 125 - }, - { - "y" : 83, - "name" : "#003", - "drilldown" : "003" - }, - { - "name" : "#004", - "drilldown" : "004", - "y" : 99 - }, - { - "drilldown" : "005", - "name" : "#005", - "y" : 78 - }, - { - "y" : 58, - "name" : "#006", - "drilldown" : "006" - }, - { - "y" : 64, - "name" : "#007", - "drilldown" : "007" - }, - { - "y" : 78, - "name" : "#008", - "drilldown" : "008" - }, - { - "y" : 76, - "drilldown" : "009", - "name" : "#009" - }, - { - "drilldown" : "010", - "name" : "#010", - "y" : 65 - }, - { - "y" : 85, - "name" : "#011", - "drilldown" : "011" - }, - { - "y" : 89, - "name" : "#012", - "drilldown" : "012" - }, - { - "y" : 85, - "drilldown" : "013", - "name" : "#013" - }, - { - "drilldown" : "014", - "name" : "#014", - "y" : 101 - }, - { - "name" : "#015", - "drilldown" : "015", - "y" : 99 - }, - { - "name" : "#016", - "drilldown" : "016", - "y" : 71 - }, - { - "drilldown" : "017", - "name" : "#017", - "y" : 84 - }, - { - "drilldown" : "018", - "name" : "#018", - "y" : 81 - }, - { - "drilldown" : "019", - "name" : "#019", - "y" : 103 - }, - { - "y" : 101, - "drilldown" : "020", - "name" : "#020" - }, - { - "drilldown" : "021", - "name" : "#021", - "y" : 72 - }, - { - "drilldown" : "022", - "name" : "#022", - "y" : 68 - }, - { - "drilldown" : "023", - "name" : "#023", - "y" : 97 - }, - { - "name" : "#024", - "drilldown" : "024", - "y" : 75 - }, - { - "drilldown" : "025", - "name" : "#025", - "y" : 59 - }, - { - "name" : "#026", - "drilldown" : "026", - "y" : 74 - }, |
