diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-11-20 08:39:22 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-11-20 08:39:22 +0000 |
| commit | e07c2ddd5c20d692cbfa5fc6fe8872c1a28e3737 (patch) | |
| tree | 480b728e666b86a8eaee6a437b074a8847e0df84 | |
| parent | 5a091b80df0de536a0144850c943a1b95c43bd1f (diff) | |
| download | perlweeklychallenge-club-e07c2ddd5c20d692cbfa5fc6fe8872c1a28e3737.tar.gz perlweeklychallenge-club-e07c2ddd5c20d692cbfa5fc6fe8872c1a28e3737.tar.bz2 perlweeklychallenge-club-e07c2ddd5c20d692cbfa5fc6fe8872c1a28e3737.zip | |
- Added solutions by Laurent Rosenfeld.
| -rw-r--r-- | challenge-139/laurent-rosenfeld/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-139/laurent-rosenfeld/perl/ch-1.pl | 15 | ||||
| -rw-r--r-- | challenge-139/laurent-rosenfeld/perl/ch-2.pl | 47 | ||||
| -rw-r--r-- | challenge-139/laurent-rosenfeld/raku/ch-1.raku | 9 | ||||
| -rw-r--r-- | challenge-139/laurent-rosenfeld/raku/ch-2.raku | 13 | ||||
| -rw-r--r-- | stats/pwc-current.json | 209 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 62 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 934 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 360 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 118 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 46 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 106 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 108 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 102 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 38 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 130 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 58 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 30 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 548 |
19 files changed, 1521 insertions, 1413 deletions
diff --git a/challenge-139/laurent-rosenfeld/blog.txt b/challenge-139/laurent-rosenfeld/blog.txt new file mode 100644 index 0000000000..4fbd74f225 --- /dev/null +++ b/challenge-139/laurent-rosenfeld/blog.txt @@ -0,0 +1 @@ +http://blogs.perl.org/users/laurent_r/2021/11/perl-weekly-challenge-139-jortsort-and-long-primes.html diff --git a/challenge-139/laurent-rosenfeld/perl/ch-1.pl b/challenge-139/laurent-rosenfeld/perl/ch-1.pl new file mode 100644 index 0000000000..eb5f91d753 --- /dev/null +++ b/challenge-139/laurent-rosenfeld/perl/ch-1.pl @@ -0,0 +1,15 @@ +use strict; +use warnings; +use feature "say"; + +sub jortsort { + my @in = @_; + for my $i (1..$#in) { + return 0 if $in[$i - 1] > $in[$i]; + } + return 1; +} + +for my $a ([1,2,3,4,5], [1,3,2,4,5]) { + say "@$a -> ", jortsort @$a; +} diff --git a/challenge-139/laurent-rosenfeld/perl/ch-2.pl b/challenge-139/laurent-rosenfeld/perl/ch-2.pl new file mode 100644 index 0000000000..33ff9f9870 --- /dev/null +++ b/challenge-139/laurent-rosenfeld/perl/ch-2.pl @@ -0,0 +1,47 @@ +use strict; +use warnings; +use feature "say"; +use constant MAX => 800; + +my $count = 0; + +sub generate_primes { + my @primes = (2, 3, 5, 7); + my $current = 9; + while (1) { + my $prime = 1; # True + for my $i (@primes) { + my $i_sq = $i * $i; + last if $i_sq > $current; + $prime = 0, last if $current % $i == 0; + } + push @primes, $current if $prime;; + $current += 2; + last if $current > MAX; + } + return @primes; +} + +sub invert { + my $n = shift; + my $dividend = 1; + my $result; + my $max = 2 * $n; + while (1) { + $dividend *= 10; + $result .= int($dividend / $n); + return $result if length $result >= $n; + my $remainder = $dividend % $n; + $dividend = $remainder; + } + return $result; +} + +my @primes = generate_primes; +for my $candidate (@primes[3..30]) { + + my $decimals = invert $candidate; + my $len = length $decimals; + ++$count and say "$candidate $decimals " unless $decimals =~ /(\d{3,$len})\1/; + last if $count >= 5; +} diff --git a/challenge-139/laurent-rosenfeld/raku/ch-1.raku b/challenge-139/laurent-rosenfeld/raku/ch-1.raku new file mode 100644 index 0000000000..d409c3f074 --- /dev/null +++ b/challenge-139/laurent-rosenfeld/raku/ch-1.raku @@ -0,0 +1,9 @@ +use v6; + +sub jortsort (@in) { + + [<=] @in; # + numifies the Boolean result +} + +for (1,2,3,4,5), (1,3,2,4,5) -> @test { + say "@test[] -> ", jortsort @test; +} diff --git a/challenge-139/laurent-rosenfeld/raku/ch-2.raku b/challenge-139/laurent-rosenfeld/raku/ch-2.raku new file mode 100644 index 0000000000..eaf008acfd --- /dev/null +++ b/challenge-139/laurent-rosenfeld/raku/ch-2.raku @@ -0,0 +1,13 @@ +use v6; + +my @primes = grep { .is-prime }, 1..Inf; +my $count = 0; + +sub is-long-prime ( UInt $den) { + my ($non-rep, $repeating) = (1 / $den).base-repeating; + return True if $repeating.chars == $den - 1; +} +for @primes -> $candidate { + say $candidate and ++$count if is-long-prime $candidate; + last if $count >= 5 +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 826263d61f..9e2f0f8319 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,23 +1,12 @@ { - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "legend" : { - "enabled" : 0 - }, "subtitle" : { - "text" : "[Champions: 23] Last updated at 2021-11-20 08:15:14 GMT" - }, - "chart" : { - "type" : "column" + "text" : "[Champions: 24] Last updated at 2021-11-20 08:31:55 GMT" }, "drilldown" : { "series" : [ { - "name" : "Abigail", "id" : "Abigail", + "name" : "Abigail", "data" : [ [ "Perl", @@ -36,11 +25,11 @@ 1 ] ], - "id" : "Andrew Shitov", - "name" : "Andrew Shitov" + "name" : "Andrew Shitov", + "id" : "Andrew Shitov" }, { - "id" : "Athanasius", + "name" : "Athanasius", "data" : [ [ "Perl", @@ -51,21 +40,21 @@ 2 ] ], - "name" : "Athanasius" + "id" : "Athanasius" }, { - "name" : "Cheok-Yin Fung", "data" : [ [ "Perl", 2 ] ], + "name" : "Cheok-Yin Fung", "id" : "Cheok-Yin Fung" }, { - "name" : "Cristina Heredia", "id" : "Cristina Heredia", + "name" : "Cristina Heredia", "data" : [ [ "Perl", @@ -75,6 +64,7 @@ }, { "id" : "Dave Jacoby", + "name" : "Dave Jacoby", "data" : [ [ "Perl", @@ -84,12 +74,11 @@ "Blog", 1 ] - ], - "name" : "Dave Jacoby" + ] }, { - "name" : "E. Choroba", "id" : "E. Choroba", + "name" : "E. Choroba", "data" : [ [ "Perl", @@ -98,6 +87,7 @@ ] }, { + "id" : "Flavio Poletti", "data" : [ [ "Perl", @@ -112,10 +102,11 @@ 2 ] ], - "id" : "Flavio Poletti", "name" : "Flavio Poletti" }, { + "id" : "James Smith", + "name" : "James Smith", "data" : [ [ "Perl", @@ -125,9 +116,7 @@ "Blog", 1 ] - ], - "id" : "James Smith", - "name" : "James Smith" + ] }, { "name" : "Jan Krnavek", @@ -140,17 +129,34 @@ "id" : "Jan Krnavek" }, { + "id" : "Jorg Sommrey", + "name" : "Jorg Sommrey", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { "data" : [ [ "Perl", 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 ] ], - "id" : "Jorg Sommrey", - "name" : "Jorg Sommrey" + "name" : "Laurent Rosenfeld", + "id" : "Laurent Rosenfeld" }, { - "name" : "Luca Ferrari", "data" : [ [ "Raku", @@ -161,6 +167,7 @@ 4 ] ], + "name" : "Luca Ferrari", "id" : "Luca Ferrari" }, { @@ -174,44 +181,44 @@ "name" : "Mark Anderson" }, { - "name" : "Niels van Dijke", "data" : [ [ "Perl", 2 ] ], + "name" : "Niels van Dijke", "id" : "Niels van Dijke" }, { - "id" : "Olivier Delouya", + "name" : "Olivier Delouya", "data" : [ [ "Perl", 1 ] ], - "name" : "Olivier Delouya" + "id" : "Olivier Delouya" }, { + "id" : "Paulo Custodio", "data" : [ [ "Perl", 2 ] ], - "id" : "Paulo Custodio", "name" : "Paulo Custodio" }, { + "name" : "Peter Campbell Smith", "data" : [ [ "Perl", 2 ] ], - "id" : "Peter Campbell Smith", - "name" : "Peter Campbell Smith" + "id" : "Peter Campbell Smith" }, { "name" : "Robert DiCicco", @@ -243,6 +250,7 @@ }, { "id" : "Simon Green", + "name" : "Simon Green", "data" : [ [ "Perl", @@ -252,20 +260,20 @@ "Blog", 1 ] - ], - "name" : "Simon Green" + ] }, { - "id" : "Steven Wilson", + "name" : "Steven Wilson", "data" : [ [ "Perl", 1 ] ], - "name" : "Steven Wilson" + "id" : "Steven Wilson" }, { + "name" : "Ulrich Rieke", "data" : [ [ "Perl", @@ -276,8 +284,7 @@ 2 ] ], - "id" : "Ulrich Rieke", - "name" : "Ulrich Rieke" + "id" : "Ulrich Rieke" }, { "name" : "W. Luis Mochan", @@ -298,108 +305,116 @@ "title" : { "text" : "The Weekly Challenge - 139" }, - "plotOptions" : { - "series" : { - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 - } + "xAxis" : { + "type" : "category" }, "tooltip" : { - "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", "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/>" }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + } + } + }, "series" : [ { - "colorByPoint" : 1, + "name" : "The Weekly Challenge - 139", "data" : [ { - "y" : 4, "name" : "Abigail", - "drilldown" : "Abigail" + "drilldown" : "Abigail", + "y" : 4 }, { - "drilldown" : "Andrew Shitov", + "y" : 1, "name" : "Andrew Shitov", - "y" : 1 + "drilldown" : "Andrew Shitov" }, { - "name" : "Athanasius", "drilldown" : "Athanasius", + "name" : "Athanasius", "y" : 4 }, { - "y" : 2, + "name" : "Cheok-Yin Fung", "drilldown" : "Cheok-Yin Fung", - "name" : "Cheok-Yin Fung" + "y" : 2 }, { + "y" : 1, "name" : "Cristina Heredia", - "drilldown" : "Cristina Heredia", - "y" : 1 + "drilldown" : "Cristina Heredia" }, { - "drilldown" : "Dave Jacoby", "name" : "Dave Jacoby", + "drilldown" : "Dave Jacoby", "y" : 3 }, { - "drilldown" : "E. Choroba", + "y" : 2, "name" : "E. Choroba", - "y" : 2 + "drilldown" : "E. Choroba" }, { + "y" : 6, "name" : "Flavio Poletti", - "drilldown" : "Flavio Poletti", - "y" : 6 + "drilldown" : "Flavio Poletti" }, { - "y" : 3, + "name" : "James Smith", "drilldown" : "James Smith", - "name" : "James Smith" + "y" : 3 }, { - "y" : 2, + "name" : "Jan Krnavek", "drilldown" : "Jan Krnavek", - "name" : "Jan Krnavek" + "y" : 2 }, { - "name" : "Jorg Sommrey", "drilldown" : "Jorg Sommrey", + "name" : "Jorg Sommrey", "y" : 2 }, { + "y" : 5, + "name" : "Laurent Rosenfeld", + "drilldown" : "Laurent Rosenfeld" + }, + { + "y" : 6, "drilldown" : "Luca Ferrari", - "name" : "Luca Ferrari", - "y" : 6 + "name" : "Luca Ferrari" }, { "y" : 2, - "name" : "Mark Anderson", - "drilldown" : "Mark Anderson" + "drilldown" : "Mark Anderson", + "name" : "Mark Anderson" }, { + "y" : 2, "name" : "Niels van Dijke", - "drilldown" : "Niels van Dijke", - "y" : 2 + "drilldown" : "Niels van Dijke" }, { "y" : 1, - "drilldown" : "Olivier Delouya", - "name" : "Olivier Delouya" + "name" : "Olivier Delouya", + "drilldown" : "Olivier Delouya" }, { "y" : 2, - "name" : "Paulo Custodio", - "drilldown" : "Paulo Custodio" + "drilldown" : "Paulo Custodio", + "name" : "Paulo Custodio" }, { + "y" : 2, "name" : "Peter Campbell Smith", - "drilldown" : "Peter Campbell Smith", - "y" : 2 + "drilldown" : "Peter Campbell Smith" }, { "name" : "Robert DiCicco", @@ -407,14 +422,14 @@ "y" : 1 }, { - "y" : 5, + "name" : "Roger Bell_West", "drilldown" : "Roger Bell_West", - "name" : "Roger Bell_West" + "y" : 5 }, { - "y" : 3, + "drilldown" : "Simon Green", "name" : "Simon Green", - "drilldown" : "Simon Green" + "y" : 3 }, { "y" : 1, @@ -422,20 +437,28 @@ "name" : "Steven Wilson" }, { - "drilldown" : "Ulrich Rieke", + "y" : 4, "name" : "Ulrich Rieke", - "y" : 4 + "drilldown" : "Ulrich Rieke" }, { "y" : 3, - "name" : "W. Luis Mochan", - "drilldown" : "W. Luis Mochan" + "drilldown" : "W. Luis Mochan", + "name" : "W. Luis Mochan" } ], - "name" : "The Weekly Challenge - 139" + "colorByPoint" : 1 } ], - "xAxis" : { - "type" : "category" + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "legend" : { + "enabled" : 0 + }, + "chart" : { + "type" : "column" } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 2450ad0c92..5a61cfc256 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,10 +1,10 @@ { - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - }, "title" : { "text" : "The Weekly Challenge Contributions [2019 - 2021]" }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, "xAxis" : { "type" : "category", "labels" : { @@ -14,50 +14,50 @@ } } }, + "subtitle" : { + "text" : "Last updated at 2021-11-20 08:31:55 GMT" + }, + "chart" : { + "type" : "column" + }, + "legend" : { + "enabled" : "false" + }, "series" : [ { - "name" : "Contributions", - "dataLabels" : { - "y" : 10, - "enabled" : "true", - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - }, - "align" : "right", - "format" : "{point.y:.0f}", - "rotation" : -90, - "color" : "#FFFFFF" - }, "data" : [ [ "Blog", - 2028 + 2029 ], [ "Perl", - 6677 + 6679 ], [ "Raku", - 4035 + 4037 ] - ] + ], + "name" : "Contributions", + "dataLabels" : { + "y" : 10, + "enabled" : "true", + "color" : "#FFFFFF", + "rotation" : -90, + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + }, + "align" : "right", + "format" : "{point.y:.0f}" + } } ], "yAxis" : { - "min" : 0, "title" : { "text" : null - } - }, - "chart" : { - "type" : "column" - }, - "subtitle" : { - "text" : "Last updated at 2021-11-20 08:15:14 GMT" - }, - "legend" : { - "enabled" : "false" + }, + "min" : 0 } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 17602a8e35..c4142aa744 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,12 +1,30 @@ { + "xAxis" : { + "type" : "category" + }, + "tooltip" : { + "followPointer" : "true", + "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>", + "headerFormat" : "<span style=\"font-size:11px\"></span>" + }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + } + } + }, "title" : { "text" : "The Weekly Challenge Language" }, + "subtitle" : { + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2021-11-20 08:31:55 GMT" + }, "drilldown" : { "series" : [ { - "name" : "001", - "id" : "001", "data" : [ [ "Perl", @@ -20,10 +38,13 @@ "Blog", 11 ] - ] + ], + "name" : "001", + "id" : "001" }, { "id" : "002", + "name" : "002", "data" : [ [ "Perl", @@ -37,8 +58,7 @@ "Blog", 10 ] - ], - "name" : "002" + ] }, { "name" : "003", @@ -59,7 +79,7 @@ "id" : "003" }, { - "name" : "004", + "id" : "004", "data" : [ [ "Perl", @@ -74,10 +94,10 @@ 10 ] ], - "id" : "004" + "name" : "004" }, { - "name" : "005", + "id" : "005", "data" : [ [ "Perl", @@ -92,9 +112,10 @@ 12 ] ], - "id" : "005" + "name" : "005" }, { + "id" : "006", "name" : "006", "data" : [ [ @@ -109,8 +130,7 @@ "Blog", 7 ] - ], - "id" : "006" + ] }, { "name" : "007", @@ -131,6 +151,7 @@ "id" : "007" }, { + "id" : "008", "name" : "008", "data" : [ [ @@ -145,12 +166,9 @@ "Blog", 12 ] - ], - "id" : "008" + ] }, { - "name" : "009", - "id" : "009", "data" : [ [ "Perl", @@ -164,11 +182,12 @@ "Blog", 13 ] - ] + ], + "name" : "009", + "id" : "009" }, { "name" : "010", - "id" : "010", "data" : [ [ "Perl", @@ -182,9 +201,12 @@ "Blog", 11 ] - ] + ], + "id" : "010" }, { + "id" : "011", + "name" : "011", "data" : [ [ "Perl", @@ -198,11 +220,10 @@ "Blog", 10 ] - ], - "id" : "011", - "name" : "011" + ] }, { + "name" : "012", "data" : [ [ "Perl", @@ -217,12 +238,11 @@ 11 ] ], - "id" : "012", - "name" : "012" + "id" : "012" }, { - "name" : "013", "id" : "013", + "name" : "013", "data" : [ [ "Perl", @@ -239,6 +259,7 @@ ] }, { + "name" : "014", "data" : [ [ "Perl", @@ -253,12 +274,9 @@ 15 ] ], - "id" : "014", - "name" : "014" + "id" : "014" }, { - "name" : "015", - "id" : "015", "data" : [ [ "Perl", @@ -272,10 +290,11 @@ "Blog", 15 ] - ] + ], + "name" : "015", + "id" : "015" }, { - "id" : "016", "data" : [ [ "Perl", @@ -290,7 +309,8 @@ 12 ] ], - "name" : "016" + "name" : "016", + "id" : "016" }, { "name" : "017", @@ -311,7 +331,7 @@ "id" : "017" }, { - "name" : "018", + "id" : "018", "data" : [ [ "Perl", @@ -326,11 +346,11 @@ 14 ] ], - "id" : "018" + "name" : "018" }, { - "name" : "019", "id" : "019", + "name" : "019", "data" : [ [ "Perl", @@ -347,7 +367,7 @@ ] }, { - "id" : "020", + "name" : "020", "data" : [ [ "Perl", @@ -362,10 +382,9 @@ 13 ] ], - "name" : "020" + "id" : "020" }, { - "name" : "021", "id" : "021", "data" : [ [ @@ -380,10 +399,11 @@ "Blog", 10 ] - ] + ], + "name" : "021" }, { - "id" : "022", + "name" : "022", "data" : [ [ "Perl", @@ -398,11 +418,11 @@ 10 ] ], - "name" : "022" + "id" : "022" }, { - "name" : "023", "id" : "023", + "name" : "023", "data" : [ [ "Perl", @@ -419,6 +439,7 @@ ] }, { + "name" : "024", "data" : [ [ "Perl", @@ -433,11 +454,10 @@ 11 ] ], - "id" : "024", - "name" : "024" + "id" : "024" }, { - "name" : "025", + "id" : "025", "data" : [ [ "Perl", @@ -452,7 +472,7 @@ 12 ] ], - "id" : "025" + "name" : "025" }, { "data" : [ @@ -469,11 +489,10 @@ 10 ] ], - "id" : "026", - "name" : "026" + "name" : "026", + "id" : "026" }, { - "name" : "027", "id" : "027", "data" : [ [ @@ -488,9 +507,12 @@ "Blog", 9 ] - ] + ], + "name" : "027" }, { + "id" : "028", + "name" : "028", "data" : [ [ "Perl", @@ -504,9 +526,7 @@ "Blog", 9 |
