diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2019-06-12 15:50:47 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2019-06-12 15:50:47 +0100 |
| commit | 5dcfe623ac277f0f09e02089046f62d393ec88d2 (patch) | |
| tree | ae93659d981fc5b6c7edeabd6ac5012980958258 | |
| parent | 776c8d8977078a23d418c1065035ec4d0a00f94d (diff) | |
| download | perlweeklychallenge-club-5dcfe623ac277f0f09e02089046f62d393ec88d2.tar.gz perlweeklychallenge-club-5dcfe623ac277f0f09e02089046f62d393ec88d2.tar.bz2 perlweeklychallenge-club-5dcfe623ac277f0f09e02089046f62d393ec88d2.zip | |
- Added solutions by Steven Wilson.
| -rw-r--r-- | challenge-012/steven-wilson/perl5/ch-1.pl | 51 | ||||
| -rw-r--r-- | challenge-012/steven-wilson/perl5/ch-2.pl | 56 | ||||
| -rw-r--r-- | stats/pwc-current.json | 125 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 80 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 228 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 486 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 122 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 96 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 24 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 44 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 226 |
11 files changed, 830 insertions, 708 deletions
diff --git a/challenge-012/steven-wilson/perl5/ch-1.pl b/challenge-012/steven-wilson/perl5/ch-1.pl new file mode 100644 index 0000000000..04f2415357 --- /dev/null +++ b/challenge-012/steven-wilson/perl5/ch-1.pl @@ -0,0 +1,51 @@ +#!/usr/bin/env perl +# Author: Steven Wilson +# Date: 2019-06-10 +# Week: 012 +# Challenge: #1 +# +# The numbers formed by adding one to the products of the smallest +# primes are called the Euclid Numbers (see wiki). Write a script that +# finds the smallest Euclid Number that is not prime. This challenge was +# proposed by Laurent Rosenfeld. + +use strict; +use warnings; +use Math::Complex; +use feature qw / say /; + +use Test::More tests => 5; +ok( is_prime(2) == 1, "2 is a prime" ); +ok( is_prime(3) == 1, "3 is a prime" ); +ok( is_prime(4) == 0, "4 is not a prime" ); +ok( is_prime(97) == 1, "97 is a prime" ); +ok( is_prime(30031) == 0, "30031 is not a prime" ); + +my $number_to_check = 2; +my $product_of_primes = 1; +my $smallest_euclid_found = 0; + +while ( !$smallest_euclid_found ) { + if ( is_prime($number_to_check) ) { + $product_of_primes *= $number_to_check; + if ( !is_prime( $product_of_primes + 1 ) ) { + $smallest_euclid_found = 1; + } + } + $number_to_check++; +} + +say $product_of_primes + 1, + " is the first Euclid Number that is not a prime."; + +sub is_prime { + my $number = shift; + my $is_prime = 1; + for ( 2 .. sqrt($number) ) { + if ( $number % $_ == 0 ) { + $is_prime = 0; + last; + } + } + return $is_prime; +} diff --git a/challenge-012/steven-wilson/perl5/ch-2.pl b/challenge-012/steven-wilson/perl5/ch-2.pl new file mode 100644 index 0000000000..83cdf4201c --- /dev/null +++ b/challenge-012/steven-wilson/perl5/ch-2.pl @@ -0,0 +1,56 @@ +#!/usr/bin/env perl +# Author: Steven Wilson +# Date: 2019-06-10 +# Week: 012 +# Challenge: #2 +# +# Write a script that finds the common directory path, given a +# collection of paths and directory separator. For example, if the +# following paths are supplied. +# +# /a/b/c/d +# /a/b/cd +# /a/b/cc +# /a/b/c/d/e +# +# and the path separator is /. Your script should return /a/b as common +# directory path. + +use strict; +use warnings; +use feature qw / say /; + +my @paths = qw# /a/b/c/d /a/b/cd /a/b/cc /a/b/c/d/e #; +my @path_dirs; +my $common_path; + +for (@paths) { + my @dirs = split m#/#, $_; + push @path_dirs, \@dirs; +} + +my $common_length = @{ $path_dirs[0] }; + +for ( 1 .. ( scalar @path_dirs - 1 ) ) { + my $count = 0; + my $difference_found = 0; + my $compare_length = @{ $path_dirs[$_]}; + while ( !$difference_found ) { + if ( $count < $common_length + && $count < $compare_length + && @{ $path_dirs[0] }[$count] eq @{ $path_dirs[$_] }[$count]) + { + $count++; + } + else { + $difference_found = 1; + } + } + if ( $count < $common_length ) { + $common_length = $count; + } +} + +$common_path = join "/", splice( @{ $path_dirs[0] }, 0, $common_length ); + +say "The common directory path is $common_path."; diff --git a/stats/pwc-current.json b/stats/pwc-current.json index f6ffc92884..91443c51aa 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,38 +1,46 @@ { + "tooltip" : { + "followPointer" : 1, + "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", + "pointerFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>" + }, + "subtitle" : { + "text" : "[Champions: 10] Last updated at 2019-06-12 14:49:20 GMT" + }, "drilldown" : { "series" : [ { - "id" : "Aaron Sherman", "data" : [ [ "Perl 6", 2 ] ], - "name" : "Aaron Sherman" + "name" : "Aaron Sherman", + "id" : "Aaron Sherman" }, { "id" : "Arne Sommer", - "name" : "Arne Sommer", "data" : [ [ "Perl 6", 2 ] - ] + ], + "name" : "Arne Sommer" }, { + "id" : "Gustavo Chaves", "name" : "Gustavo Chaves", "data" : [ [ "Perl 5", 2 ] - ], - "id" : "Gustavo Chaves" + ] }, { - "name" : "Joelle Maslak", + "id" : "Joelle Maslak", "data" : [ [ "Perl 5", @@ -43,17 +51,17 @@ 1 ] ], - "id" : "Joelle Maslak" + "name" : "Joelle Maslak" }, { + "id" : "Kevin Colyer", "name" : "Kevin Colyer", "data" : [ [ "Perl 6", 2 ] - ], - "id" : "Kevin Colyer" + ] }, { "id" : "Ozzy", @@ -66,24 +74,34 @@ "name" : "Ozzy" }, { + "id" : "Rakesh Kumar Shardiwal", "name" : "Rakesh Kumar Shardiwal", "data" : [ [ "Perl 5", 2 ] - ], - "id" : "Rakesh Kumar Shardiwal" + ] }, { - "id" : "Simon Proctor", "name" : "Simon Proctor", "data" : [ [ "Perl 6", 2 ] - ] + ], + "id" : "Simon Proctor" + }, + { + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "name" : "Steven Wilson", + "id" : "Steven Wilson" }, { "name" : "Yozen Hernandez", @@ -97,40 +115,20 @@ } ] }, - "tooltip" : { - "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", - "pointerFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", - "followPointer" : 1 - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "subtitle" : { - "text" : "[Champions: 9] Last updated at 2019-06-12 10:22:18 GMT" - }, - "title" : { - "text" : "Perl Weekly Challenge - 012" - }, - "plotOptions" : { - "series" : { - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 - } - }, - "legend" : { - "enabled" : 0 - }, "xAxis" : { "type" : "category" }, "chart" : { "type" : "column" }, + "legend" : { + "enabled" : 0 + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, "series" : [ { "colorByPoint" : 1, @@ -147,41 +145,58 @@ }, { "y" : 2, - "drilldown" : "Gustavo Chaves", - "name" : "Gustavo Chaves" + "name" : "Gustavo Chaves", + "drilldown" : "Gustavo Chaves" }, { - "y" : 2, "name" : "Joelle Maslak", - "drilldown" : "Joelle Maslak" + "drilldown" : "Joelle Maslak", + "y" : 2 }, { + "y" : 2, "drilldown" : "Kevin Colyer", - "name" : "Kevin Colyer", - "y" : 2 + "name" : "Kevin Colyer" }, { - "drilldown" : "Ozzy", "name" : "Ozzy", + "drilldown" : "Ozzy", "y" : 1 }, { - "name" : "Rakesh Kumar Shardiwal", + "y" : 2, "drilldown" : "Rakesh Kumar Shardiwal", - "y" : 2 + "name" : "Rakesh Kumar Shardiwal" }, { - "drilldown" : "Simon Proctor", + "y" : 2, "name" : "Simon Proctor", - "y" : 2 + "drilldown" : "Simon Proctor" }, { "y" : 2, + "name" : "Steven Wilson", + "drilldown" : "Steven Wilson" + }, + { + "drilldown" : "Yozen Hernandez", "name" : "Yozen Hernandez", - "drilldown" : "Yozen Hernandez" + "y" : 2 } ], "name" : "Champions" } - ] + ], + "title" : { + "text" : "Perl Weekly Challenge - 012" + }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + } + } + } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 3911d28584..a1b34fbca0 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,40 +1,6 @@ { - "xAxis" : { - "labels" : { - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - } - }, - "type" : "category" - }, - "subtitle" : { - "text" : "Last updated at 2019-06-12 10:22:38 GMT" - }, - "yAxis" : { - "min" : 0, - "title" : { - "text" : null - } - }, - "legend" : { - "enabled" : "false" - }, "series" : [ { - "name" : "Contributions", - "dataLabels" : { - "enabled" : "true", - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - }, - "y" : 10, - "rotation" : -90, - "align" : "right", - "color" : "#FFFFFF", - "format" : "{point.y:.0f}" - }, "data" : [ [ "Blog", @@ -42,22 +8,56 @@ ], [ "Perl 5", - 454 + 456 ], [ "Perl 6", 269 ] - ] + ], + "name" : "Contributions", + "dataLabels" : { + "rotation" : -90, + "color" : "#FFFFFF", + "align" : "right", + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + }, + "format" : "{point.y:.0f}", + "y" : 10, + "enabled" : "true" + } } ], - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" + "chart" : { + "type" : "column" + }, + "yAxis" : { + "title" : { + "text" : null + }, + "min" : 0 }, "title" : { "text" : "Perl Weekly Challenge Contributions - 2019" }, - "chart" : { - "type" : "column" + "legend" : { + "enabled" : "false" + }, + "subtitle" : { + "text" : "Last updated at 2019-06-12 14:49:34 GMT" + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "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 afb1be9d7d..e6bd9dec94 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,91 +1,25 @@ { - "plotOptions" : { - "series" : { - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 + "yAxis" : { + "title" : { + "text" : "Total Solutions" } }, + "title" : { + "text" : "Perl Weekly Challenge Language" + }, "legend" : { "enabled" : "false" }, - "series" : [ - { - "data" : [ - { - "drilldown" : "001", - "y" : 113, - "name" : "#001 [P5=76 P6=37]" - }, - { - "y" : 95, - "drilldown" : "002", - "name" : "#002 [P5=63 P6=32]" - }, - { - "name" : "#003 [P5=32 P6=26]", - "drilldown" : "003", - "y" : 58 - }, - { - "name" : "#004 [P5=46 P6=29]", - "drilldown" : "004", - "y" : 75 - }, - { - "drilldown" : "005", - "y" : 55, - "name" : "#005 [P5=33 P6=22]" - }, - { - "y" : 41, - "drilldown" : "006", - "name" : "#006 [P5=27 P6=14]" - }, - { - "y" : 46, - "drilldown" : "007", - "name" : "#007 [P5=26 P6=20]" - }, - { - "y" : 58, - "drilldown" : "008", - "name" : "#008 [P5=38 P6=20]" - }, - { - "y" : 51, - "drilldown" : "009", - "name" : "#009 [P5=33 P6=18]" - }, - { - "name" : "#010 [P5=32 P6=15]", - "drilldown" : "010", - "y" : 47 - }, - { - "name" : "#011 [P5=41 P6=26]", - "drilldown" : "011", - "y" : 67 - }, - { - "drilldown" : "012", - "y" : 17, - "name" : "#012 [P5=7 P6=10]" - } - ], - "name" : "Perl Weekly Challenge Languages", - "colorByPoint" : "true" - } - ], + "tooltip" : { + "followPointer" : "true", + "pointFormat" : "<span style=\"color:{point.color}\">{point.name}</span>: <b>{point.y:f}</b><br/>", + "headerFormat" : "<span style=\"font-size:11px\"></span>" + }, "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2019-06-12 10:22:38 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2019-06-12 14:49:34 GMT" }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } + "chart" : { + "type" : "column" }, "xAxis" : { "type" : "category" @@ -93,8 +27,6 @@ "drilldown" : { "series" : [ { - "name" : "001", - "id" : "001", "data" : [ [ "Perl 5", @@ -104,10 +36,11 @@ "Perl 6", 37 ] - ] + ], + "id" : "001", + "name" : "001" }, { - "id" : "002", "data" : [ [ "Perl 5", @@ -118,7 +51,8 @@ 32 ] ], - "name" : "002" + "name" : "002", + "id" : "002" }, { "data" : [ @@ -131,11 +65,10 @@ 26 ] ], - "id" : "003", - "name" : "003" + "name" : "003", + "id" : "003" }, { - "id" : "004", "data" : [ [ "Perl 5", @@ -146,10 +79,10 @@ 29 ] ], + "id" : "004", "name" : "004" }, { - "name" : "005", "data" : [ [ "Perl 5", @@ -160,11 +93,12 @@ 22 ] ], + "name" : "005", "id" : "005" }, { - "name" : "006", "id" : "006", + "name" : "006", "data" : [ [ "Perl 5", @@ -177,6 +111,7 @@ ] }, { + "name" : "007", "id" : "007", "data" : [ [ @@ -187,11 +122,11 @@ "Perl 6", 20 ] - ], - "name" : "007" + ] }, { "id" : "008", + "name" : "008", "data" : [ [ "Perl 5", @@ -201,10 +136,10 @@ "Perl 6", 20 ] - ], - "name" : "008" + ] }, { + "name" : "009", "id" : "009", "data" : [ [ @@ -215,10 +150,11 @@ "Perl 6", 18 ] - ], - "name" : "009" + ] }, { + "name" : "010", + "id" : "010", "data" : [ [ "Perl 5", @@ -228,13 +164,11 @@ "Perl 6", 15 ] - ], - "id" : "010", - "name" : "010" + ] }, { - "name" : "011", "id" : "011", + "name" : "011", "data" : [ [ "Perl 5", @@ -247,30 +181,96 @@ ] }, { + "name" : "012", + "id" : "012", "data" : [ [ "Perl 5", - 7 + 9 ], [ "Perl 6", 10 ] - ], - "id" : "012", - "name" : "012" + ] } ] }, - "chart" : { - "type" : "column" - }, - "tooltip" : { - "followPointer" : "true", - "pointFormat" : "<span style=\"color:{point.color}\">{point.name}</span>: <b>{point.y:f}</b><br/>", - "headerFormat" : "<span style=\"font-size:11px\"></span>" - }, - "title" : { - "text" : "Perl Weekly Challenge Language" + "series" : [ + { + "colorByPoint" : "true", + "data" : [ + { + "drilldown" : "001", + "name" : "#001 [P5=76 P6=37]", + "y" : 113 + }, + { + "y" : 95, + "name" : "#002 [P5=63 P6=32]", + "drilldown" : "002" + }, + { + "y" : 58, + "name" : "#003 [P5=32 P6=26]", + "drilldown" : "003" + }, + { + "name" : "#004 [P5=46 P6=29]", + "y" : 75, + "drilldown" : "004" + }, + { + "drilldown" : "005", + "name" : "#005 [P5=33 P6=22]", + "y" : 55 + }, + { + "y" : 41, + "name" : "#006 [P5=27 P6=14]", + "drilldown" : "006" + }, + { + "drilldown" : "007", + "y" : 46, + "name" : "#007 [P5=26 P6=20]" + }, + { + "y" : 58, + "name" : "#008 [P5=38 P6=20]", + "drilldown" : "008" + }, + { + "name" : "#009 [P5=33 P6=18]", + "y" : 51, + "drilldown" : "009" + }, + { + "name" : "#010 [P5=32 P6=15]", + "y" : 47, + "drilldown" : "010" + }, + { + "drilldown" : "011", + "y" : 67, + "name" : "#011 [P5=41 P6=26]" + }, + { + "drilldown" : "012", + "name" : "#012 [P5=9 P6=10]", + "y" : 19 + } + ], + "name" : "Perl Weekly Challenge Languages" + } + ], + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } } } diff --git a/stats/pwc-leaders.json b/stats/pwc-leaders.json index 99de73c0d4..c072b30c72 100644 --- a/stats/pwc-leaders.json +++ b/stats/pwc-leaders.json @@ -1,14 +1,23 @@ { - "yAxis" : { - "title" : { - "text" : "Total Score" - } + "chart" : { + "type" : "column" }, - "title" : { - "text" : "Perl Weekly Challenge Leaders (TOP 50)" + "tooltip" : { + "headerFormat" : "<span style=\"font-size:11px\"></span>", + "pointFormat" : "<span style=\"color:{point.color}\">{point.name}</span>: <b>{point.y:f}</b><br/>", + "followPointer" : "true" }, - "subtitle" : { - "text" : "Click the columns to drilldown the score breakdown. Last updated at 2019-06-12 10:22:33 GMT" + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, + "xAxis" : { + "type" : "category" }, "drilldown" : { "series" : [ @@ -17,39 +26,38 @@ "name" : "Joelle Maslak", "data" : [ [ + "Perl 5", + 27 + ], + [ "Perl 6", 27 ], [ "Blog", 3 - ], - [ - "Perl 5", - 27 ] ] }, { "data" : [ [ - "Perl 5", - 22 + "Perl 6", + 21 ], [ "Blog", 13 ], [ - "Perl 6", - 21 + "Perl 5", + 22 ] ], "name" : "Laurent Rosenfeld", "id" : "Laurent Rosenfeld" }, { - "id" : "Jaldhar H. Vyas", "data" : [ [ "Perl 6", @@ -60,11 +68,10 @@ 22 ] ], + "id" : "Jaldhar H. Vyas", "name" : "Jaldhar H. Vyas" }, { - "id" : "Ruben Westerberg", - "name" : "Ruben Westerberg", "data" : [ [ "Perl 5", @@ -74,57 +81,59 @@ "Perl 6", 19 ] - ] + ], + "name" : "Ruben Westerberg", + "id" : "Ruben Westerberg" }, { + "name" : "Adam Russell", + "id" : "Adam Russell", "data" : [ [ - "Blog", - 11 - ], - [ "Perl 5", 22 + ], + [ + "Blog", + 11 ] - ], - "name" : "Adam Russell", - "id" : "Adam Russell" + ] }, { "data" : [ [ - "Blog", - 11 - ], - [ "Perl 6", 21 + ], + [ + "Blog", + 11 ] ], - "name" : "Arne Sommer", - "id" : "Arne Sommer" + "id" : "Arne Sommer", + "name" : "Arne Sommer" }, { "name" : "Simon Proctor", + "id" : "Simon Proctor", "data" : [ [ + "Perl 5", + 4 + ], + [ "Perl 6", 20 ], [ "Blog", 6 - ], - [ - "Perl 5", - 4 ] - ], - "id" : "Simon Proctor" + ] }, { - "id" : "Kian-Meng Ang", "name" : "Kian-Meng Ang", + "id" : "Kian-Meng Ang", "data" : [ [ "Blog", @@ -137,36 +146,36 @@ ] }, { - "id" : "Gustavo Chaves", - "name" : "Gustavo Chaves", "data" : [ [ - "Blog", - 4 - ], - [ "Perl 5", 21 + ], + [ + "Blog", + 4 ] - ] + ], + "name" : "Gustavo Chaves", + "id" : "Gustavo Chaves" }, { + "name" : "Jo Christian Oterhals", "id" : "Jo Christian Oterhals", "data" : [ [ - "Blog", - 6 - ], - [ "Perl 6", 12 ], [ + "Blog", + 6 + ], + [ "Perl 5", 6 ] - ], - "name" : "Jo Christian Oterhals" + ] }, { "data" : [ @@ -179,45 +188,44 @@ "id" : "Athanasius" }, { + "id" : "Dr James A. Smith", "name" : "Dr James A. Smith", "data" : [ [ - "Perl 5", - 12 - ], - [ "Perl 6", 10 + ], + [ + "Perl 5", + 12 ] - ], - "id" : "Dr James A. Smith" + ] }, { + "name" : "Francis Whittle", "id" : "Francis Whittle", "data" : [ [ - "Perl 6", - 16 - ], - [ "Blog", 6 + ], + [ + "Perl 6", + 16 ] - ], - "name" : "Francis Whittle" + ] }, { + "id" : "Andrezgz", "name" : "Andrezgz", "data" : [ [ "Perl 5", 21 ] - ], - "id" : "Andrezgz" + ] }, { - "id" : "E. Choroba", "data" : [ [ "Perl 5", @@ -228,58 +236,58 @@ 7 ] ], - "name" : "E. Choroba" + "name" : "E. Choroba", + "id" : "E. Choroba" }, { "data" : [ [ - "Blog", + "Perl 5", 9 ], [ - "Perl 5", + "Blog", 9 ] ], - "name" : "Dave Jacoby",< |
