diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-10-13 18:44:53 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-10-13 18:44:53 +0100 |
| commit | ace3e8d314fab84624d1498c05d228e5ab6df16b (patch) | |
| tree | 1d5dd2bc48608a10a0402cfc4f44fa56e12eb64f | |
| parent | 6558d46f76a09cd795afcef69a29dd276fdffd8c (diff) | |
| download | perlweeklychallenge-club-ace3e8d314fab84624d1498c05d228e5ab6df16b.tar.gz perlweeklychallenge-club-ace3e8d314fab84624d1498c05d228e5ab6df16b.tar.bz2 perlweeklychallenge-club-ace3e8d314fab84624d1498c05d228e5ab6df16b.zip | |
- Added solutions by Peter Campbell Smith.
| -rwxr-xr-x | challenge-134/peter-campbell-smith/perl/ch-1.pl | 33 | ||||
| -rwxr-xr-x | challenge-134/peter-campbell-smith/perl/ch-2.pl | 49 | ||||
| -rw-r--r-- | stats/pwc-current.json | 141 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 42 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 1006 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 382 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 52 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 54 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 114 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 104 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 56 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 18 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 46 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 126 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 538 |
16 files changed, 1449 insertions, 1352 deletions
diff --git a/challenge-134/peter-campbell-smith/perl/ch-1.pl b/challenge-134/peter-campbell-smith/perl/ch-1.pl new file mode 100755 index 0000000000..62aa948707 --- /dev/null +++ b/challenge-134/peter-campbell-smith/perl/ch-1.pl @@ -0,0 +1,33 @@ +#!/usr/bin/perl + +# Peter Campbell Smith - 2021-10-13 +# PWC 134 task 1 + +use v5.20; +use warnings; + +# Write a script to generate first 5 Pandigital Numbers in base 10. +# A pandigital number is an integer that in a given base has among its significant +# digits each digit used in the base at least once. + +# The first such number is 1023456789 as we can't start with 0 which isn't 'significant'. +# +# The simplest way to find the next 4 is simply to test every subsequent integer +# until all 5 are found. Even if you are looking for the first 1000 pandigitals +# this completes in a few seconds. + +my ($test, $count, $limit); + +$limit = 5; # how many do we want +$count = 0; # how many have we found + +# start with the known first one and test subsequent integers +$test = 1023456789; +while (1) { + if ($test =~ m|0| and $test =~ m|1| and $test =~ m|2| and $test =~ m|3| and $test =~ m|4| + and $test =~ m|5| and $test =~ m|6| and $test =~ m|7| and $test =~ m|8| and $test =~ m|9|) { + say $test; + last if ++$count == $limit; + } + $test ++; +} diff --git a/challenge-134/peter-campbell-smith/perl/ch-2.pl b/challenge-134/peter-campbell-smith/perl/ch-2.pl new file mode 100755 index 0000000000..997399252a --- /dev/null +++ b/challenge-134/peter-campbell-smith/perl/ch-2.pl @@ -0,0 +1,49 @@ +#!/usr/bin/perl + +# Peter Campbell Smith - 2021-10-13 +# PWC 134 task 2 + +# You are given 2 positive numbers, $m and $n. +# Write a script to generate multiplication table and display count of distinct terms. + +# Formatting the output is probably the hardest aspect of this challenge! + +use strict; +use warnings; + +my ($m, $n, $col_width, $j, $k, $term, %terms, $line, $count); + +# get params +print qq[m: ]; $m = <> + 0; +print qq[n: ]; $n = <> + 0; +print qq[\nInput: \$m = $m, \$n = $n\nOutput:\n\n]; + +# calculate column width = width of largest term + 1 +$col_width = int(log($m * $n)/log(10)) + 1; + +# print top row and underline +print sprintf(" %${col_width}s", 'x') . ' |'; +for $j (1 .. $n) { + print sprintf(" %${col_width}d", $j); +} +print qq[\n]; +print '-' x ($col_width + 2) . '+' . '-' x (($col_width + 1) * $n) . "\n"; + +# print other rows +for $j (1 .. $m) { + print sprintf(" %${col_width}d", $j) . ' |'; + for $k (1 .. $n) { + $term = $j * $k; + print sprintf(" %${col_width}d", $term); + $terms{sprintf('%08d', $term)} = 1; # pad to 8 digits to make them sort correctly + } + print qq[\n]; +} + +# print unique terms +for $term (sort keys %terms) { + $line .= ($term + 0) . ', '; + $count ++; +} + +print qq[\nDistinct terms: ] . substr($line, 0, -2) . qq[\nCount: $count\n\n]; diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 485621240a..d45d73fec2 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,4 +1,23 @@ { + "title" : { + "text" : "The Weekly Challenge - 134" + }, + "xAxis" : { + "type" : "category" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "chart" : { + "type" : "column" + }, + "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" : [ { "data" : [ @@ -8,9 +27,9 @@ "drilldown" : "Andinus" }, { + "name" : "Andrezgz", "y" : 2, - "drilldown" : "Andrezgz", - "name" : "Andrezgz" + "drilldown" : "Andrezgz" }, { "drilldown" : "Dave Jacoby", @@ -19,38 +38,43 @@ }, { "y" : 2, - "drilldown" : "James Smith", - "name" : "James Smith" + "name" : "James Smith", + "drilldown" : "James Smith" }, { - "y" : 4, + "drilldown" : "Luca Ferrari", "name" : "Luca Ferrari", - "drilldown" : "Luca Ferrari" + "y" : 4 }, { "name" : "Mark Anderson", - "drilldown" : "Mark Anderson", + "y" : 2, + "drilldown" : "Mark Anderson" + }, + { + "drilldown" : "Mohammad S Anwar", + "name" : "Mohammad S Anwar", "y" : 2 }, { + "drilldown" : "Olivier Delouya", "y" : 2, - "name" : "Mohammad S Anwar", - "drilldown" : "Mohammad S Anwar" + "name" : "Olivier Delouya" }, { + "drilldown" : "Peter Campbell Smith", "y" : 2, - "name" : "Olivier Delouya", - "drilldown" : "Olivier Delouya" + "name" : "Peter Campbell Smith" }, { + "name" : "Roger Bell_West", "y" : 4, - "drilldown" : "Roger Bell_West", - "name" : "Roger Bell_West" + "drilldown" : "Roger Bell_West" }, { + "y" : 2, "name" : "Simon Proctor", - "drilldown" : "Simon Proctor", - "y" : 2 + "drilldown" : "Simon Proctor" }, { "y" : 3, @@ -58,23 +82,19 @@ "drilldown" : "Ulrich Rieke" }, { - "y" : 3, + "drilldown" : "W. Luis Mochan", "name" : "W. Luis Mochan", - "drilldown" : "W. Luis Mochan" + "y" : 3 } ], - "colorByPoint" : 1, - "name" : "The Weekly Challenge - 134" + "name" : "The Weekly Challenge - 134", + "colorByPoint" : 1 } ], - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, "drilldown" : { "series" : [ { + "id" : "Andinus", "data" : [ [ "Raku", @@ -85,8 +105,7 @@ 1 ] ], - "name" : "Andinus", - "id" : "Andinus" + "name" : "Andinus" }, { "data" : [ @@ -99,7 +118,6 @@ "id" : "Andrezgz" }, { - "id" : "Dave Jacoby", "name" : "Dave Jacoby", "data" : [ [ @@ -110,7 +128,8 @@ "Blog", 1 ] - ] + ], + "id" : "Dave Jacoby" }, { "id" : "James Smith", @@ -123,6 +142,7 @@ ] }, { + "name" : "Luca Ferrari", "data" : [ [ "Raku", @@ -133,40 +153,51 @@ 2 ] ], - "name" : "Luca Ferrari", "id" : "Luca Ferrari" }, { - "name" : "Mark Anderson", - "id" : "Mark Anderson", "data" : [ [ "Raku", 2 ] - ] + ], + "name" : "Mark Anderson", + "id" : "Mark Anderson" }, { + "name" : "Mohammad S Anwar", "data" : [ [ "Perl", 2 ] ], - "name" : "Mohammad S Anwar", "id" : "Mohammad S Anwar" }, { + "id" : "Olivier Delouya", + "name" : "Olivier Delouya", "data" : [ [ "Perl", 2 ] - ], - "id" : "Olivier Delouya", - "name" : "Olivier Delouya" + ] + }, + { + "id" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith", + "data" : [ + [ + "Perl", + 2 + ] + ] }, { + "id" : "Roger Bell_West", + "name" : "Roger Bell_West", "data" : [ [ "Perl", @@ -176,9 +207,7 @@ "Raku", 2 ] - ], - "name" : "Roger Bell_West", - "id" : "Roger Bell_West" + ] }, { "data" : [ @@ -191,7 +220,6 @@ "id" : "Simon Proctor" }, { - "id" : "Ulrich Rieke", "name" : "Ulrich Rieke", "data" : [ [ @@ -202,7 +230,8 @@ "Raku", 2 ] - ] + ], + "id" : "Ulrich Rieke" }, { "data" : [ @@ -220,33 +249,19 @@ } ] }, - "tooltip" : { - "followPointer" : 1, - "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/>" - }, - "xAxis" : { - "type" : "category" - }, - "chart" : { - "type" : "column" + "legend" : { + "enabled" : 0 }, - "title" : { - "text" : "The Weekly Challenge - 134" + "subtitle" : { + "text" : "[Champions: 13] Last updated at 2021-10-13 17:43:21 GMT" }, "plotOptions" : { "series" : { - "borderWidth" : 0, "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - } + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 } - }, - "subtitle" : { - "text" : "[Champions: 12] Last updated at 2021-10-13 17:15:41 GMT" - }, - "legend" : { - "enabled" : 0 } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 5a25579400..0a87ad4b18 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,23 +1,20 @@ { - "legend" : { - "enabled" : "false" - }, "subtitle" : { - "text" : "Last updated at 2021-10-13 17:15:41 GMT" + "text" : "Last updated at 2021-10-13 17:43:21 GMT" }, "series" : [ { "dataLabels" : { "y" : 10, - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - }, - "rotation" : -90, "color" : "#FFFFFF", + "format" : "{point.y:.0f}", "align" : "right", "enabled" : "true", - "format" : "{point.y:.0f}" + "rotation" : -90, + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + } }, "name" : "Contributions", "data" : [ @@ -27,7 +24,7 @@ ], [ "Perl", - 6362 + 6364 ], [ "Raku", @@ -36,6 +33,15 @@ ] } ], + "legend" : { + "enabled" : "false" + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "chart" : { + "type" : "column" + }, "yAxis" : { "title" : { "text" : null @@ -45,19 +51,13 @@ "title" : { "text" : "The Weekly Challenge Contributions [2019 - 2021]" }, - "chart" : { - "type" : "column" - }, "xAxis" : { + "type" : "category", "labels" : { "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" } - }, - "type" : "category" - }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" + } } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 36a271b06c..723741a1b1 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,9 +1,33 @@ { + "chart" : { + "type" : "column" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "xAxis" : { + "type" : "category" + }, + "title" : { + "text" : "The Weekly Challenge Language" + }, + "subtitle" : { + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2021-10-13 17:43:21 GMT" + }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + }, + "borderWidth" : 0 + } + }, "drilldown" : { "series" : [ { - "name" : "001", - "id" : "001", "data" : [ [ "Perl", @@ -17,9 +41,12 @@ "Blog", 11 ] - ] + ], + "name" : "001", + "id" : "001" }, { + "id" : "002", "data" : [ [ "Perl", @@ -34,10 +61,11 @@ 10 ] ], - "name" : "002", - "id" : "002" + "name" : "002" }, { + "id" : "003", + "name" : "003", "data" : [ [ "Perl", @@ -51,13 +79,10 @@ "Blog", 9 ] - ], - "id" : "003", - "name" : "003" + ] }, { "id" : "004", - "name" : "004", "data" : [ [ "Perl", @@ -71,11 +96,10 @@ "Blog", 10 ] - ] + ], + "name" : "004" }, { - "name" : "005", - "id" : "005", "data" : [ [ "Perl", @@ -89,9 +113,13 @@ "Blog", 12 ] - ] + ], + "name" : "005", + "id" : "005" }, { + "id" : "006", + "name" : "006", "data" : [ [ "Perl", @@ -105,12 +133,9 @@ "Blog", 7 ] - ], - "name" : "006", - "id" : "006" + ] }, { - "name" : "007", "id" : "007", "data" : [ [ @@ -125,9 +150,12 @@ "Blog", 10 ] - ] + ], + "name" : "007" }, { + "id" : "008", + "name" : "008", "data" : [ [ "Perl", @@ -141,12 +169,9 @@ "Blog", 12 ] - ], - "name" : "008", - "id" : "008" + ] }, { - "name" : "009", "id" : "009", "data" : [ [ @@ -161,11 +186,11 @@ "Blog", 13 ] - ] + ], + "name" : "009" }, { "id" : "010", - "name" : "010", "data" : [ [ "Perl", @@ -179,9 +204,12 @@ "Blog", 11 ] - ] + ], + "name" : "010" }, { + "id" : "011", + "name" : "011", "data" : [ [ "Perl", @@ -195,13 +223,10 @@ "Blog", 10 ] - ], - "id" : "011", - "name" : "011" + ] }, { "name" : "012", - "id" : "012", "data" : [ [ "Perl", @@ -215,11 +240,10 @@ "Blog", 11 ] - ] + ], + "id" : "012" }, { - "id" : "013", - "name" : "013", "data" : [ [ "Perl", @@ -233,10 +257,11 @@ "Blog", 13 ] - ] + ], + "name" : "013", + "id" : "013" }, { - "id" : "014", "name" : "014", "data" : [ [ @@ -251,9 +276,11 @@ "Blog", 15 ] - ] + ], + "id" : "014" }, { + "id" : "015", "data" : [ [ "Perl", @@ -268,8 +295,7 @@ 15 ] ], - "name" : "015", - "id" : "015" + "name" : "015" }, { "data" : [ @@ -286,10 +312,12 @@ 12 ] ], - "id" : "016", - "name" : "016" + "name" : "016", + "id" : "016" }, { + "id" : "017", + "name" : "017", "data" : [ [ "Perl", @@ -303,11 +331,11 @@ "Blog", 12 ] - ], - "id" : "017", - "name" : "017" + ] }, { + "id" : "018", + "name" : "018", "data" : [ [ "Perl", @@ -321,13 +349,11 @@ "Blog", 14 ] - ], - "name" : "018", - "id" : "018" + ] }, { - "name" : "019", "id" : "019", + "name" : "019", "data" : [ [ "Perl", @@ -344,6 +370,8 @@ ] }, { + "id" : "020", + "name" : "020", "data" : [ [ "Perl", @@ -357,13 +385,10 @@ "Blog", 13 ] - ], - "id" : "020", - "name" : "020" + ] }, { "id" : "021", - "name" : "021", "data" : [ [ "Perl", @@ -377,9 +402,12 @@ "Blog", 10 ] - ] + ], + "name" : "021" }, { + "id" : "022", + "name" : "022", "data" : [ [ "Perl", @@ -393,11 +421,10 @@ "Blog", 10 ] - ], - "name" : "022", - "id" : "022" + ] }, { + "name" : "023", "data" : [ [ "Perl", @@ -412,10 +439,11 @@ 12 ] ], - "id" : "023", - "name" : "023" + "id" : "023" }, { + "id" : "024", + "name" : "024", "data" : [ [ "Perl", @@ -429,11 +457,10 @@ "Blog", 11 ] - ], - "id" : "024", - "name" : "024" + ] }, { + "name" : "025", "data" : [ [ "Perl", @@ -448,12 +475,11 @@ 12 ] ], - "id" : "025", - "name" : "025" + "id" : "025" }, { - "name" : "026", "id" : "026", + "name" : "026", "data" : [ [ "Perl", @@ -470,8 +496,8 @@ ] }, { - "name" : "027", "id" : "027", + "name" : "027", "data" : [ [ "Perl", @@ -488,6 +514,8 @@ ] }, { + "id" : "028", + "name" : "028", "data" : [ [ "Perl", @@ -501,11 +529,10 @@ "Blog", 9 ] - ], - "id" : "028", - "name" : "028" + ] }, { + "id" : "029", "data" : [ [ "Perl", @@ -520,12 +547,9 @@ 12 ] ], - "name" : "029", - "id" : "029" + "name" : "029" }, { - "id" : "030", - "name" : "030", "data" : [ [ "Perl", @@ -539,9 +563,13 @@ "Blog", 10 ] - ] + ], + "name" : "030", + "id" : "030" }, { + "id" : "031", + "name" : "031", "data" : [ [ "Perl", @@ -555,12 +583,9 @@ "Blog", 9 ] - ], - "name" : "031", - "id" : "031" + ] }, { - "id" : "032", "name" : "032", "data" : [ [ @@ -575,10 +600,10 @@ "Blog", 10 ] - ] + ], + "id" : "032" }, { - "name" : "033", "id" : "033", "data" : [ [ @@ -593,9 +618,11 @@ "Blog", 10 ] - ] + ], + "name" : "033" }, { + "id" : "034", "data" : [ [ "Perl", @@ -610,8 +637,7 @@ 11 ] ], - "name" : "034", - "id" : "034" + "name" : "034" }, { "id" : "035", @@ -632,8 +658,6 @@ ] }, { - "id" : "036", - "name" : "036", "data" : [ [ "Perl", @@ -647,11 +671,11 @@ "Blog", 11 ] - ] + ], + "name" : "036", + "id" : "036" }, { - "name" : "037", - "id" : "037", "data" : [ [ "Perl", @@ -665,9 +689,13 @@ "Blog", 9 ] - ] + ], + "name" : "037", + "id" : "037" }, { + "id" : "038", + "name" : "038", "data" : [ [ "Perl", @@ -681,9 +709,7 @@ "Blog", 12 ] - ], - "name" : "038", - "id" : "038" + ] }, { "data" : [ @@ -700,10 +726,11 @@ 12 ] ], - "id" : "039", - "name" : "039" + "name" : "039", + "id" : "039" }, { + "name" : "040", "data" : [ [ "Perl", @@ -718,8 +745,7 @@ 10 ] ], - "id" : "040", - "name" : "040" + "id" : "040" }, { "data" : [ @@ -736,11 +762,10 @@ 9 ] ], - "id" : "041", - "name" : "041" + "name" : "041", + "id" : "041" }, { - "name" : "042", "id" : "042", "data" : [ [ @@ -755,9 +780,11 @@ "Blog", 11 ] - ] + ], + "name" : "042" }, { + "name" : "043", "data" : [ [ "Perl", @@ -772,10 +799,10 @@ 11 ] ], - "id" : "043", - "name" : "043" + "id" : "043" }, { + "name" : "044", "data" : [ [ "Perl", @@ -790,10 +817,10 @@ 11 ] ], - "id" : "044", - "name" : "044" + "id" : "044" }, { + "id" : "045", "data" : [ [ "Perl", @@ -808,7 +835,6 @@ 11 ] ], - "id" : "045", "name" : "045" }, { @@ -844,11 +870,10 @@ 10 ] ], - "id" : "047", - "name" : "047" + "name" : "047", + "id" : "047" }, { |
