diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-11-24 00:41:56 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-11-24 00:41:56 +0000 |
| commit | 5c2d1e2ff6d4c85c12278bb37cc2ccb6fe036764 (patch) | |
| tree | 841a4b84c1e807e186cfadb2c7dcf5375ceaf534 | |
| parent | 40638ae4192845aa5e1fc43e402f49aeb1e6074a (diff) | |
| download | perlweeklychallenge-club-5c2d1e2ff6d4c85c12278bb37cc2ccb6fe036764.tar.gz perlweeklychallenge-club-5c2d1e2ff6d4c85c12278bb37cc2ccb6fe036764.tar.bz2 perlweeklychallenge-club-5c2d1e2ff6d4c85c12278bb37cc2ccb6fe036764.zip | |
- Added solutions by Peter Campbell Smith.
| -rwxr-xr-x | challenge-140/peter-campbell-smith/perl/ch-1.pl | 51 | ||||
| -rwxr-xr-x | challenge-140/peter-campbell-smith/perl/ch-2.pl | 39 | ||||
| -rw-r--r-- | stats/pwc-challenge-139.json | 642 | ||||
| -rw-r--r-- | stats/pwc-current.json | 639 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 66 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 967 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 404 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 120 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 114 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 42 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 48 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 36 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 36 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 38 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 106 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 108 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 538 |
17 files changed, 2085 insertions, 1909 deletions
diff --git a/challenge-140/peter-campbell-smith/perl/ch-1.pl b/challenge-140/peter-campbell-smith/perl/ch-1.pl new file mode 100755 index 0000000000..a98e0fae66 --- /dev/null +++ b/challenge-140/peter-campbell-smith/perl/ch-1.pl @@ -0,0 +1,51 @@ +#!/usr/bin/perl + +# Peter Campbell Smith - 2021-11-22 +# PWC 140 task 1 + +use v5.20; +use warnings; +use strict; + +# You are given two decimal-coded binary numbers, $a and $b. + +# Write a script to simulate the addition of the given binary numbers. +# The script should simulate something like $a + $b. (operator overloading) + +my (@tests, $a, $b); + +# pairs to be added +@tests = (11, 1, 101, 1, 100, 11, 10101, 1010, 0, 111, 1111111111, 1111111111); + +while (1) { + + # pick off next pair + $a = shift @tests; + last unless length($a); + $b = shift @tests; + + # give answer + say qq[$a + $b = ] . dec_to_bin(bin_to_dec($a) + bin_to_dec($b)); +} + +sub bin_to_dec { + + # converts a string of 0s and 1s to a decimal value + my ($arg, $result); + + $arg = $_[0]; + $result = 0; + + # process digits + while ($arg =~ m|^(.)(.*)$|) { + $result = 2 * $result + $1; + $arg = $2; + } + return $result; +} + +sub dec_to_bin { + + # coverts a decimal number to binary representation + return sprintf('%b', $_[0]); +} diff --git a/challenge-140/peter-campbell-smith/perl/ch-2.pl b/challenge-140/peter-campbell-smith/perl/ch-2.pl new file mode 100755 index 0000000000..ba0291a889 --- /dev/null +++ b/challenge-140/peter-campbell-smith/perl/ch-2.pl @@ -0,0 +1,39 @@ +#!/usr/bin/perl + +# Peter Campbell Smith - 2021-11-22 +# PWC 140 task 2 + +use v5.20; +use warnings; +use strict; + +# You are given 3 positive integers, $i, $j and $k. +# Write a script to print the $kth element in the sorted +# multiplication table of $i and $j. + +my (@tests, $test, $i, $j, $k, @results, $i0, $j0); + +# i, j, k sets to be tested +@tests = ([2, 3, 4], [3, 3, 6], [20, 30, 599], [1000, 999, 314159]); + +# loop over tests +for $test (@tests) { + + # we want the $nth product in $results[$n] so dummy out $results[0] + @results = (0); + ($i, $j, $k) = @$test; + say qq[Input: \$i = $i, \$j = $j, \$k = $k]; + + # make table + for $i0 (1 .. $i) { + for $j0 (1 .. $j) { + push (@results, $i0 * $j0); + } + } + + # sort results and print desired one + @results = sort {$a <=> $b} @results; + + say qq[Output: $results[$k]\n]; +} + diff --git a/stats/pwc-challenge-139.json b/stats/pwc-challenge-139.json new file mode 100644 index 0000000000..8b50f622ba --- /dev/null +++ b/stats/pwc-challenge-139.json @@ -0,0 +1,642 @@ +{ + "series" : [ + { + "data" : [ + { + "name" : "Abigail", + "y" : 4, + "drilldown" : "Abigail" + }, + { + "name" : "Adam Russell", + "y" : 4, + "drilldown" : "Adam Russell" + }, + { + "drilldown" : "Andrew Shitov", + "y" : 1, + "name" : "Andrew Shitov" + }, + { + "drilldown" : "Arne Sommer", + "y" : 3, + "name" : "Arne Sommer" + }, + { + "name" : "Athanasius", + "y" : 4, + "drilldown" : "Athanasius" + }, + { + "name" : "Cheok-Yin Fung", + "y" : 2, + "drilldown" : "Cheok-Yin Fung" + }, + { + "y" : 5, + "name" : "Colin Crain", + "drilldown" : "Colin Crain" + }, + { + "name" : "Cristina Heredia", + "y" : 1, + "drilldown" : "Cristina Heredia" + }, + { + "y" : 3, + "name" : "Dave Jacoby", + "drilldown" : "Dave Jacoby" + }, + { + "drilldown" : "Duncan C. White", + "name" : "Duncan C. White", + "y" : 2 + }, + { + "y" : 2, + "name" : "E. Choroba", + "drilldown" : "E. Choroba" + }, + { + "drilldown" : "Flavio Poletti", + "y" : 6, + "name" : "Flavio Poletti" + }, + { + "name" : "Jake", + "y" : 1, + "drilldown" : "Jake" + }, + { + "name" : "Jaldhar H. Vyas", + "y" : 5, + "drilldown" : "Jaldhar H. Vyas" + }, + { + "drilldown" : "James Smith", + "name" : "James Smith", + "y" : 3 + }, + { + "y" : 2, + "name" : "Jan Krnavek", + "drilldown" : "Jan Krnavek" + }, + { + "drilldown" : "Jorg Sommrey", + "name" : "Jorg Sommrey", + "y" : 2 + }, + { + "y" : 5, + "name" : "Laurent Rosenfeld", + "drilldown" : "Laurent Rosenfeld" + }, + { + "name" : "Lubos Kolouch", + "y" : 2, + "drilldown" : "Lubos Kolouch" + }, + { + "y" : 6, + "name" : "Luca Ferrari", + "drilldown" : "Luca Ferrari" + }, + { + "y" : 2, + "name" : "Mark Anderson", + "drilldown" : "Mark Anderson" + }, + { + "drilldown" : "Matthew Neleigh", + "y" : 2, + "name" : "Matthew Neleigh" + }, + { + "drilldown" : "Mohammad S Anwar", + "name" : "Mohammad S Anwar", + "y" : 2 + }, + { + "drilldown" : "Niels van Dijke", + "name" : "Niels van Dijke", + "y" : 2 + }, + { + "y" : 1, + "name" : "Olivier Delouya", + "drilldown" : "Olivier Delouya" + }, + { + "y" : 2, + "name" : "Paulo Custodio", + "drilldown" : "Paulo Custodio" + }, + { + "y" : 2, + "name" : "Pete Houston", + "drilldown" : "Pete Houston" + }, + { + "drilldown" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith", + "y" : 2 + }, + { + "drilldown" : "Robert DiCicco", + "name" : "Robert DiCicco", + "y" : 1 + }, + { + "drilldown" : "Roger Bell_West", + "name" : "Roger Bell_West", + "y" : 5 + }, + { + "drilldown" : "Simon Green", + "y" : 3, + "name" : "Simon Green" + }, + { + "y" : 1, + "name" : "Steven Wilson", + "drilldown" : "Steven Wilson" + }, + { + "drilldown" : "Ulrich Rieke", + "y" : 4, + "name" : "Ulrich Rieke" + }, + { + "drilldown" : "W. Luis Mochan", + "name" : "W. Luis Mochan", + "y" : 3 + } + ], + "colorByPoint" : 1, + "name" : "The Weekly Challenge - 139" + } + ], + "xAxis" : { + "type" : "category" + }, + "subtitle" : { + "text" : "[Champions: 34] Last updated at 2021-11-24 00:38:42 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/>" + }, + "chart" : { + "type" : "column" + }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "title" : { + "text" : "The Weekly Challenge - 139" + }, + "drilldown" : { + "series" : [ + { + "id" : "Abigail", + "name" : "Abigail", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 2 + ] + ] + }, + { + "id" : "Adam Russell", + "name" : "Adam Russell", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 2 + ] + ] + }, + { + "name" : "Andrew Shitov", + "id" : "Andrew Shitov", + "data" : [ + [ + "Raku", + 1 + ] + ] + }, + { + "name" : "Arne Sommer", + "id" : "Arne Sommer", + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "id" : "Athanasius", + "name" : "Athanasius", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ] + }, + { + "name" : "Cheok-Yin Fung", + "id" : "Cheok-Yin Fung", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Colin Crain", + "id" : "Colin Crain" + }, + { + "data" : [ + [ + "Perl", + 1 + ] + ], + "name" : "Cristina Heredia", + "id" : "Cristina Heredia" + }, + { + "id" : "Dave Jacoby", + "name" : "Dave Jacoby", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "id" : "Duncan C. White", + "name" : "Duncan C. White", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "name" : "E. Choroba", + "id" : "E. Choroba", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "id" : "Flavio Poletti", + "name" : "Flavio Poletti", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 2 + ] + ] + }, + { + "id" : "Jake", + "name" : "Jake", + "data" : [ + [ + "Perl", + 1 + ] + ] + }, + { + "id" : "Jaldhar H. Vyas", + "name" : "Jaldhar H. Vyas", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "id" : "James Smith", + "name" : "James Smith", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "id" : "Jan Krnavek", + "name" : "Jan Krnavek", + "data" : [ + [ + "Raku", + 2 + ] + ] + }, + { + "id" : "Jorg Sommrey", + "name" : "Jorg Sommrey", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "id" : "Laurent Rosenfeld", + "name" : "Laurent Rosenfeld", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "name" : "Lubos Kolouch", + "id" : "Lubos Kolouch", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 4 + ] + ], + "name" : "Luca Ferrari", + "id" : "Luca Ferrari" + }, + { + "id" : "Mark Anderson", + "name" : "Mark Anderson", + "data" : [ + [ + "Raku", + 2 + ] + ] + }, + { + "id" : "Matthew Neleigh", + "name" : "Matthew Neleigh", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "id" : "Mohammad S Anwar", + "name" : "Mohammad S Anwar", + "data" : [ + [ + "Perl", + 1 + ], + [ + "Raku", + 1 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Niels van Dijke", + "id" : "Niels van Dijke" + }, + { + "data" : [ + [ + "Perl", + 1 + ] + ], + "id" : "Olivier Delouya", + "name" : "Olivier Delouya" + }, + { + "name" : "Paulo Custodio", + "id" : "Paulo Custodio", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "id" : "Pete Houston", + "name" : "Pete Houston", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Peter Campbell Smith", + "id" : "Peter Campbell Smith" + }, + { + "id" : "Robert DiCicco", + "name" : "Robert DiCicco", + "data" : [ + [ + "Perl", + 1 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Roger Bell_West", + "id" : "Roger Bell_West" + }, + { + "id" : "Simon Green", + "name" : "Simon Green", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 1 + ] + ], + "id" : "Steven Wilson", + "name" : "Steven Wilson" + }, + { + "id" : "Ulrich Rieke", + "name" : "Ulrich Rieke", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "W. Luis Mochan", + "name" : "W. Luis Mochan" + } + ] + }, + "legend" : { + "enabled" : 0 + } +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index f7a4e13781..6d8cddf98f 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,642 +1,63 @@ { - "chart" : { - "type" : "column" - }, "subtitle" : { - "text" : "[Champions: 34] Last updated at 2021-11-22 02:38:31 GMT" + "text" : "[Champions: 1] Last updated at 2021-11-24 00:40:38 GMT" }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + } } }, + "chart" : { + "type" : "column" + }, "xAxis" : { "type" : "category" }, "drilldown" : { "series" : [ { - "id" : "Abigail", - "name" : "Abigail", - "data" : [ - [ - "Perl", - 2 - ], - [ - "Blog", - 2 - ] - ] - }, - { - "name" : "Adam Russell", - "data" : [ - [ - "Perl", - 2 - ], - [ - "Blog", - 2 - ] - ], - "id" : "Adam Russell" - }, - { - "id" : "Andrew Shitov", - "data" : [ - [ - "Raku", - 1 - ] - ], - "name" : "Andrew Shitov" - }, - { - "id" : "Arne Sommer", - "data" : [ - [ - "Raku", - 2 - ], - [ - "Blog", - 1 - ] - ], - "name" : "Arne Sommer" - }, - { - "name" : "Athanasius", - "data" : [ - [ - "Perl", - 2 - ], - [ - "Raku", - 2 - ] - ], - "id" : "Athanasius" - }, - { - "id" : "Cheok-Yin Fung", - "name" : "Cheok-Yin Fung", - "data" : [ - [ - "Perl", - 2 - ] - ] - }, - { - "id" : "Colin Crain", - "data" : [ - [ - "Perl", - 2 - ], - [ - "Raku", - 2 - ], - [ - "Blog", - 1 - ] - ], - "name" : "Colin Crain" - }, - { - "data" : [ - [ - "Perl", - 1 - ] - ], - "name" : "Cristina Heredia", - "id" : "Cristina Heredia" - }, - { - "data" : [ - [ - "Perl", - 2 - ], - [ - "Blog", - 1 - ] - ], - "name" : "Dave Jacoby", - "id" : "Dave Jacoby" - }, - { - "id" : "Duncan C. White", - "name" : "Duncan C. White", - "data" : [ - [ - "Perl", - 2 - ] - ] - }, - { - "name" : "E. Choroba", - "data" : [ - [ - "Perl", - 2 - ] - ], - "id" : "E. Choroba" - }, - { - "id" : "Flavio Poletti", - "name" : "Flavio Poletti", - "data" : [ - [ - "Perl", - 2 - ], - [ - "Raku", - 2 - ], - [ - "Blog", - 2 - ] - ] - }, - { - "id" : "Jake", - "name" : "Jake", - "data" : [ - [ - "Perl", - 1 - ] - ] - }, - { - "id" : "Jaldhar H. Vyas", - "data" : [ - [ - "Perl", - 2 - ], - [ - "Raku", - 2 - ], - [ - "Blog", - 1 - ] - ], - "name" : "Jaldhar H. Vyas" - }, - { - "id" : "James Smith", - "data" : [ - [ - "Perl", - 2 - ], - [ - "Blog", - 1 - ] - ], - "name" : "James Smith" - }, - { - "name" : "Jan Krnavek", - "data" : [ - [ - "Raku", - 2 - ] - ], - "id" : "Jan Krnavek" - }, - { - "id" : "Jorg Sommrey", - "data" : [ - [ - "Perl", - 2 - ] - ], - "name" : "Jorg Sommrey" - }, - { - "name" : "Laurent Rosenfeld", - "data" : [ - [ - "Perl", - 2 - ], - [ - "Raku", - 2 - ], - [ - "Blog", - 1 - ] - ], - "id" : "Laurent Rosenfeld" - }, - { - "id" : "Lubos Kolouch", - "name" : "Lubos Kolouch", - "data" : [ - [ - "Perl", - 2 - ] - ] - }, - { - "data" : [ - [ - "Raku", - 2 - ], - [ - "Blog", - 4 - ] - ], - "name" : "Luca Ferrari", - "id" : "Luca Ferrari" - }, - { - "name" : "Mark Anderson", - "data" : [ - [ - "Raku", - 2 - ] - ], - "id" : "Mark Anderson" - }, - { - "id" : "Matthew Neleigh", - "data" : [ - [ - "Perl", - 2 - ] - ], - "name" : "Matthew Neleigh" - }, - { - "id" : "Mohammad S Anwar", - "data" : [ - [ - "Perl", - 1 - ], - [ - "Raku", - 1 - ] - ], - "name" : "Mohammad S Anwar" - }, - { - "id" : "Niels van Dijke", - "data" : [ - [ - "Perl", - 2 - ] - ], - "name" : "Niels van Dijke" - }, - { - "data" : [ - [ - "Perl", - 1 - ] - ], - "name" : "Olivier Delouya", - "id" : "Olivier Delouya" - }, - { - "id" : "Paulo Custodio", - "data" : [ - [ - "Perl", - 2 - ] - ], - "name" : "Paulo Custodio" - }, - { - "data" : [ - [ - "Perl", - 2 - ] - ], - "name" : "Pete Houston", - "id" : "Pete Houston" - }, - { + "name" : "Peter Campbell Smith", "id" : "Peter Campbell Smith", "data" : [ [ "Perl", 2 ] - ], |
