aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2021-11-03 08:23:02 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2021-11-03 08:23:02 +0000
commit44fe1238f7ff9315570e0cba709213130e0add3a (patch)
treed3f89d0b78345f277d593343a7387bf9d776f682
parent088bd1a9bb76f41ca7a856e3268fe8ab71cdded4 (diff)
downloadperlweeklychallenge-club-44fe1238f7ff9315570e0cba709213130e0add3a.tar.gz
perlweeklychallenge-club-44fe1238f7ff9315570e0cba709213130e0add3a.tar.bz2
perlweeklychallenge-club-44fe1238f7ff9315570e0cba709213130e0add3a.zip
- Added solutions by Laurent Rosenfeld.
-rw-r--r--challenge-137/laurent-rosenfeld/blog.txt1
-rw-r--r--challenge-137/laurent-rosenfeld/perl/ch-1.pl21
-rw-r--r--challenge-137/laurent-rosenfeld/perl/ch-2.pl19
-rw-r--r--challenge-137/laurent-rosenfeld/raku/ch-1.raku9
-rw-r--r--challenge-137/laurent-rosenfeld/raku/ch-2.raku15
-rw-r--r--stats/pwc-current.json293
-rw-r--r--stats/pwc-language-breakdown-summary.json64
-rw-r--r--stats/pwc-language-breakdown.json976
-rw-r--r--stats/pwc-leaders.json746
-rw-r--r--stats/pwc-summary-1-30.json24
-rw-r--r--stats/pwc-summary-121-150.json110
-rw-r--r--stats/pwc-summary-151-180.json92
-rw-r--r--stats/pwc-summary-181-210.json44
-rw-r--r--stats/pwc-summary-211-240.json30
-rw-r--r--stats/pwc-summary-241-270.json46
-rw-r--r--stats/pwc-summary-31-60.json106
-rw-r--r--stats/pwc-summary-61-90.json32
-rw-r--r--stats/pwc-summary-91-120.json118
-rw-r--r--stats/pwc-summary.json42
19 files changed, 1438 insertions, 1350 deletions
diff --git a/challenge-137/laurent-rosenfeld/blog.txt b/challenge-137/laurent-rosenfeld/blog.txt
new file mode 100644
index 0000000000..b0308b1b00
--- /dev/null
+++ b/challenge-137/laurent-rosenfeld/blog.txt
@@ -0,0 +1 @@
+http://blogs.perl.org/users/laurent_r/2021/11/perl-weekly-challenge-137-long-year-and-lychrel-number.html
diff --git a/challenge-137/laurent-rosenfeld/perl/ch-1.pl b/challenge-137/laurent-rosenfeld/perl/ch-1.pl
new file mode 100644
index 0000000000..884c69496d
--- /dev/null
+++ b/challenge-137/laurent-rosenfeld/perl/ch-1.pl
@@ -0,0 +1,21 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use feature qw/say/;
+use Time::Local;
+
+sub is_leap_year {
+ my $year = shift;
+ return 0 if $year % 4; # not divisible by 4
+ return 1 if $year % 100; # divisible by 4, not by 100
+ return 0 if $year % 400; # divisible by 100, not by 400
+ return 1; # divisible by 400
+}
+
+for my $year (1900..2100) {
+ my $date = timegm(0, 0, 0, 1, 0, $year);
+ my $day_in_week = (gmtime $date)[6];
+ print $year, ", " if $day_in_week == 4; # 4 = Thursday
+ print $year, ", " if $day_in_week == 3 and is_leap_year $year;
+}
+say "";
diff --git a/challenge-137/laurent-rosenfeld/perl/ch-2.pl b/challenge-137/laurent-rosenfeld/perl/ch-2.pl
new file mode 100644
index 0000000000..698e631f52
--- /dev/null
+++ b/challenge-137/laurent-rosenfeld/perl/ch-2.pl
@@ -0,0 +1,19 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use feature qw/say/;
+
+sub is_lychrel {
+ my $m = shift;
+ my $n = $m;
+ for my $i (1..500) {
+ return "$m is a Lychrel candidate. Reached the 1e7 limit"
+ if $n > 10_000_000;
+ $n += reverse $n;
+ return 0 if $n == reverse $n;
+ }
+ return "$m is a lychrel candidate (made 500 iterations)";
+}
+for my $test (10..20, 30, 50, 100, 196) {
+ say "$test -> ", is_lychrel $test;
+}
diff --git a/challenge-137/laurent-rosenfeld/raku/ch-1.raku b/challenge-137/laurent-rosenfeld/raku/ch-1.raku
new file mode 100644
index 0000000000..c1fd4311e5
--- /dev/null
+++ b/challenge-137/laurent-rosenfeld/raku/ch-1.raku
@@ -0,0 +1,9 @@
+use v6;
+
+for 1900..2100 -> $y {
+ my $year = DateTime.new(:year($y));
+ my $new-year-day = Date.new("$y-01-01").day-of-week;
+ print "$y, " if $new-year-day == 4; # DoW 4 = Thursday
+ print "$y, " if $year.is-leap-year and $new-year-day == 3;
+}
+say "";
diff --git a/challenge-137/laurent-rosenfeld/raku/ch-2.raku b/challenge-137/laurent-rosenfeld/raku/ch-2.raku
new file mode 100644
index 0000000000..97e2c89ba1
--- /dev/null
+++ b/challenge-137/laurent-rosenfeld/raku/ch-2.raku
@@ -0,0 +1,15 @@
+use v6;
+
+sub is-lychrel (UInt $m) {
+ my $n = $m;
+ for 1..500 -> $i {
+ return "$m is a Lychrel candidate. Reached the 1e7 limit"
+ if $n > 10_000_000;
+ $n += $n.flip;
+ #`[say $n and] return 0 if $n == $n.flip;
+ }
+ return "$m is a lychrel candidate (made 500 iterations)";
+}
+for 10...20, 30, 50, 100, 196 -> $test {
+ say "$test -> ", is-lychrel $test;
+}
diff --git a/stats/pwc-current.json b/stats/pwc-current.json
index ecfc7671a1..52e4950231 100644
--- a/stats/pwc-current.json
+++ b/stats/pwc-current.json
@@ -1,113 +1,4 @@
{
- "legend" : {
- "enabled" : 0
- },
- "series" : [
- {
- "name" : "The Weekly Challenge - 137",
- "data" : [
- {
- "name" : "Andrew Shitov",
- "drilldown" : "Andrew Shitov",
- "y" : 1
- },
- {
- "name" : "Bob Lied",
- "drilldown" : "Bob Lied",
- "y" : 2
- },
- {
- "y" : 6,
- "drilldown" : "Flavio Poletti",
- "name" : "Flavio Poletti"
- },
- {
- "name" : "James Smith",
- "drilldown" : "James Smith",
- "y" : 3
- },
- {
- "drilldown" : "Luca Ferrari",
- "y" : 6,
- "name" : "Luca Ferrari"
- },
- {
- "name" : "Mark Anderson",
- "drilldown" : "Mark Anderson",
- "y" : 2
- },
- {
- "name" : "Matthew Neleigh",
- "y" : 2,
- "drilldown" : "Matthew Neleigh"
- },
- {
- "name" : "Niels van Dijke",
- "drilldown" : "Niels van Dijke",
- "y" : 2
- },
- {
- "y" : 2,
- "drilldown" : "Paulo Custodio",
- "name" : "Paulo Custodio"
- },
- {
- "name" : "Robert DiCicco",
- "y" : 1,
- "drilldown" : "Robert DiCicco"
- },
- {
- "name" : "Roger Bell_West",
- "y" : 4,
- "drilldown" : "Roger Bell_West"
- },
- {
- "name" : "Simon Green",
- "drilldown" : "Simon Green",
- "y" : 3
- },
- {
- "name" : "Steven Wilson",
- "y" : 2,
- "drilldown" : "Steven Wilson"
- },
- {
- "name" : "Ulrich Rieke",
- "drilldown" : "Ulrich Rieke",
- "y" : 4
- },
- {
- "name" : "W. Luis Mochan",
- "y" : 3,
- "drilldown" : "W. Luis Mochan"
- }
- ],
- "colorByPoint" : 1
- }
- ],
- "chart" : {
- "type" : "column"
- },
- "subtitle" : {
- "text" : "[Champions: 15] Last updated at 2021-11-03 07:58:23 GMT"
- },
- "xAxis" : {
- "type" : "category"
- },
- "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/>"
- },
- "plotOptions" : {
- "series" : {
- "dataLabels" : {
- "enabled" : 1,
- "format" : "{point.y}"
- },
- "borderWidth" : 0
- }
- },
"drilldown" : {
"series" : [
{
@@ -122,16 +13,16 @@
},
{
"id" : "Bob Lied",
- "name" : "Bob Lied",
"data" : [
[
"Perl",
2
]
- ]
+ ],
+ "name" : "Bob Lied"
},
{
- "id" : "Flavio Poletti",
+ "name" : "Flavio Poletti",
"data" : [
[
"Perl",
@@ -146,7 +37,7 @@
2
]
],
- "name" : "Flavio Poletti"
+ "id" : "Flavio Poletti"
},
{
"name" : "James Smith",
@@ -163,8 +54,24 @@
"id" : "James Smith"
},
{
- "id" : "Luca Ferrari",
- "name" : "Luca Ferrari",
+ "id" : "Laurent Rosenfeld",
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Raku",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "name" : "Laurent Rosenfeld"
+ },
+ {
"data" : [
[
"Raku",
@@ -174,21 +81,23 @@
"Blog",
4
]
- ]
+ ],
+ "id" : "Luca Ferrari",
+ "name" : "Luca Ferrari"
},
{
- "id" : "Mark Anderson",
+ "name" : "Mark Anderson",
"data" : [
[
"Raku",
2
]
],
- "name" : "Mark Anderson"
+ "id" : "Mark Anderson"
},
{
- "id" : "Matthew Neleigh",
"name" : "Matthew Neleigh",
+ "id" : "Matthew Neleigh",
"data" : [
[
"Perl",
@@ -197,8 +106,8 @@
]
},
{
- "id" : "Niels van Dijke",
"name" : "Niels van Dijke",
+ "id" : "Niels van Dijke",
"data" : [
[
"Perl",
@@ -207,27 +116,26 @@
]
},
{
- "id" : "Paulo Custodio",
- "name" : "Paulo Custodio",
"data" : [
[
"Perl",
2
]
- ]
+ ],
+ "id" : "Paulo Custodio",
+ "name" : "Paulo Custodio"
},
{
+ "name" : "Robert DiCicco",
+ "id" : "Robert DiCicco",
"data" : [
[
"Perl",
1
]
- ],
- "name" : "Robert DiCicco",
- "id" : "Robert DiCicco"
+ ]
},
{
- "id" : "Roger Bell_West",
"name" : "Roger Bell_West",
"data" : [
[
@@ -238,11 +146,10 @@
"Raku",
2
]
- ]
+ ],
+ "id" : "Roger Bell_West"
},
{
- "id" : "Simon Green",
- "name" : "Simon Green",
"data" : [
[
"Perl",
@@ -252,17 +159,19 @@
"Blog",
1
]
- ]
+ ],
+ "id" : "Simon Green",
+ "name" : "Simon Green"
},
{
- "name" : "Steven Wilson",
+ "id" : "Steven Wilson",
"data" : [
[
"Perl",
2
]
],
- "id" : "Steven Wilson"
+ "name" : "Steven Wilson"
},
{
"id" : "Ulrich Rieke",
@@ -289,11 +198,125 @@
1
]
],
- "name" : "W. Luis Mochan",
- "id" : "W. Luis Mochan"
+ "id" : "W. Luis Mochan",
+ "name" : "W. Luis Mochan"
}
]
},
+ "legend" : {
+ "enabled" : 0
+ },
+ "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
+ },
+ "subtitle" : {
+ "text" : "[Champions: 16] Last updated at 2021-11-03 08:20:46 GMT"
+ },
+ "chart" : {
+ "type" : "column"
+ },
+ "series" : [
+ {
+ "colorByPoint" : 1,
+ "data" : [
+ {
+ "y" : 1,
+ "drilldown" : "Andrew Shitov",
+ "name" : "Andrew Shitov"
+ },
+ {
+ "name" : "Bob Lied",
+ "drilldown" : "Bob Lied",
+ "y" : 2
+ },
+ {
+ "y" : 6,
+ "drilldown" : "Flavio Poletti",
+ "name" : "Flavio Poletti"
+ },
+ {
+ "y" : 3,
+ "drilldown" : "James Smith",
+ "name" : "James Smith"
+ },
+ {
+ "name" : "Laurent Rosenfeld",
+ "drilldown" : "Laurent Rosenfeld",
+ "y" : 5
+ },
+ {
+ "y" : 6,
+ "drilldown" : "Luca Ferrari",
+ "name" : "Luca Ferrari"
+ },
+ {
+ "drilldown" : "Mark Anderson",
+ "name" : "Mark Anderson",
+ "y" : 2
+ },
+ {
+ "name" : "Matthew Neleigh",
+ "drilldown" : "Matthew Neleigh",
+ "y" : 2
+ },
+ {
+ "y" : 2,
+ "name" : "Niels van Dijke",
+ "drilldown" : "Niels van Dijke"
+ },
+ {
+ "y" : 2,
+ "drilldown" : "Paulo Custodio",
+ "name" : "Paulo Custodio"
+ },
+ {
+ "y" : 1,
+ "name" : "Robert DiCicco",
+ "drilldown" : "Robert DiCicco"
+ },
+ {
+ "y" : 4,
+ "drilldown" : "Roger Bell_West",
+ "name" : "Roger Bell_West"
+ },
+ {
+ "name" : "Simon Green",
+ "drilldown" : "Simon Green",
+ "y" : 3
+ },
+ {
+ "y" : 2,
+ "name" : "Steven Wilson",
+ "drilldown" : "Steven Wilson"
+ },
+ {
+ "name" : "Ulrich Rieke",
+ "drilldown" : "Ulrich Rieke",
+ "y" : 4
+ },
+ {
+ "y" : 3,
+ "name" : "W. Luis Mochan",
+ "drilldown" : "W. Luis Mochan"
+ }
+ ],
+ "name" : "The Weekly Challenge - 137"
+ }
+ ],
+ "plotOptions" : {
+ "series" : {
+ "dataLabels" : {
+ "enabled" : 1,
+ "format" : "{point.y}"
+ },
+ "borderWidth" : 0
+ }
+ },
+ "xAxis" : {
+ "type" : "category"
+ },
"title" : {
"text" : "The Weekly Challenge - 137"
},
diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json
index 1dd32a41c6..f16686196b 100644
--- a/stats/pwc-language-breakdown-summary.json
+++ b/stats/pwc-language-breakdown-summary.json
@@ -1,13 +1,4 @@
{
- "title" : {
- "text" : "The Weekly Challenge Contributions [2019 - 2021]"
- },
- "yAxis" : {
- "title" : {
- "text" : null
- },
- "min" : 0
- },
"xAxis" : {
"type" : "category",
"labels" : {
@@ -17,46 +8,55 @@
}
}
},
+ "yAxis" : {
+ "min" : 0,
+ "title" : {
+ "text" : null
+ }
+ },
+ "title" : {
+ "text" : "The Weekly Challenge Contributions [2019 - 2021]"
+ },
+ "legend" : {
+ "enabled" : "false"
+ },
"tooltip" : {
"pointFormat" : "<b>{point.y:.0f}</b>"
},
+ "subtitle" : {
+ "text" : "Last updated at 2021-11-03 08:20:46 GMT"
+ },
"series" : [
{
- "dataLabels" : {
- "style" : {
- "fontSize" : "13px",
- "fontFamily" : "Verdana, sans-serif"
- },
- "rotation" : -90,
- "enabled" : "true",
- "y" : 10,
- "format" : "{point.y:.0f}",
- "align" : "right",
- "color" : "#FFFFFF"
- },
- "name" : "Contributions",
"data" : [
[
"Blog",
- 1988
+ 1989
],
[
"Perl",
- 6554
+ 6556
],
[
"Raku",
- 3979
+ 3981
]
- ]
+ ],
+ "dataLabels" : {
+ "color" : "#FFFFFF",
+ "style" : {
+ "fontSize" : "13px",
+ "fontFamily" : "Verdana, sans-serif"
+ },
+ "format" : "{point.y:.0f}",
+ "rotation" : -90,
+ "align" : "right",
+ "y" : 10,
+ "enabled" : "true"
+ },
+ "name" : "Contributions"
}
],
- "legend" : {
- "enabled" : "false"
- },
- "subtitle" : {
- "text" : "Last updated at 2021-11-03 07:58:23 GMT"
- },
"chart" : {
"type" : "column"
}
diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json
index 4f71afcc67..4e98601dee 100644
--- a/stats/pwc-language-breakdown.json
+++ b/stats/pwc-language-breakdown.json
@@ -1,15 +1,22 @@
{
+ "yAxis" : {
+ "title" : {
+ "text" : "Total Solutions"
+ }
+ },
+ "title" : {
+ "text" : "The Weekly Challenge Language"
+ },
"xAxis" : {
"type" : "category"
},
- "tooltip" : {
- "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>",
- "followPointer" : "true",
- "headerFormat" : "<span style=\"font-size:11px\"></span>"
+ "legend" : {
+ "enabled" : "false"
},
"drilldown" : {
"series" : [
{
+ "name" : "001",
"data" : [
[
"Perl",
@@ -24,11 +31,9 @@
11
]
],
- "name" : "001",
"id" : "001"
},
{
- "name" : "002",
"data" : [
[
"Perl",
@@ -43,7 +48,8 @@
10
]
],
- "id" : "002"
+ "id" : "002",
+ "name" : "002"
},
{
"data" : [
@@ -60,10 +66,11 @@
9
]
],
- "name" : "003",
- "id" : "003"
+ "id" : "003",
+ "name" : "003"
},
{
+ "id" : "004",
"data" : [
[
"Perl",
@@ -78,10 +85,11 @@
10
]
],
- "name" : "004",
- "id" : "004"
+ "name" : "004"
},
{
+ "name" : "005",
+ "id" : "005",
"data" : [
[
"Perl",
@@ -95,11 +103,10 @@
"Blog",
12
]
- ],
- "name" : "005",
- "id" : "005"
+ ]
},
{
+ "name" : "006",
"id" : "006",
"data" : [
[
@@ -114,10 +121,10 @@
"Blog",
7
]
- ],
- "name" : "006"
+ ]
},
{
+ "name" : "007",
"id" : "007",
"data" : [
[
@@ -132,11 +139,9 @@
"Blog",
10
]
- ],
- "name" : "007"
+ ]
},
{
- "id" : "008",
"data" : [
[
"Perl",
@@ -151,10 +156,10 @@
12
]
],
+ "id" : "008",
"name" : "008"
},
{
- "id" : "009",
"data" : [
[
"Perl",
@@ -169,11 +174,11 @@
13
]
],
+ "id" : "009",
"name" : "009"
},
{
"id" : "010",
- "name" : "010",
"data" : [
[
"Perl",
@@ -187,7 +192,8 @@
"Blog",
11
]
- ]
+ ],
+ "name" : "010"
},
{
"data" : [
@@ -204,11 +210,11 @@
10
]
],
- "name" : "011",
- "id" : "011"
+ "id" : "011",
+ "name" : "011"
},
{
- "name" : "012",
+ "id" : "012",
"data" : [
[
"Perl",
@@ -223,11 +229,10 @@
11
]
],
- "id" : "012"
+ "name" : "012"
},
{
"id" : "013",
- "name" : "013",
"data" : [
[
"Perl",
@@ -241,11 +246,11 @@
"Blog",
13
]
- ]
+ ],
+ "name" : "013"
},
{
"id" : "014",
- "name" : "014",
"data" : [
[
"Perl",
@@ -259,9 +264,11 @@
"Blog",
15
]
- ]
+ ],
+ "name" : "014"
},
{
+ "name" : "015",
"id" : "015",
"data" : [
[
@@ -276,11 +283,11 @@
"Blog",
15
]
- ],
- "name" : "015"
+ ]
},
{
"name" : "016",
+ "id" : "016",
"data" : [
[
"Perl",
@@ -294,11 +301,9 @@
"Blog",
12
]
- ],
- "id" : "016"
+ ]
},
{
- "name" : "017",
"data" : [
[
"Perl",
@@ -313,11 +318,12 @@
12
]
],
- "id" : "017"
+ "id" : "017",
+ "name" : "017"
},
{
- "id" : "018",
"name" : "018",
+ "id" : "018",
"data" : [
[
"Perl",
@@ -352,8 +358,6 @@
"id" : "019"
},
{
- "id" : "020",
- "name" : "020",
"data" : [
[
"Perl",
@@ -367,10 +371,12 @@
"Blog",
13
]
- ]
+ ],
+ "id" : "020",
+ "name" : "020"
},
{
- "name" : "021",
+ "id" : "021",
"data" : [
[
"Perl",
@@ -385,9 +391,11 @@
10
]
],
- "id" : "021"
+ "name" : "021"
},
{
+ "name" : "022",
+ "id" : "022",
"data" : [
[
"Perl",
@@ -401,13 +409,9 @@
"Blog",
10
]
- ],
- "name" : "022",
- "id" : "022"
+ ]
},
{
- "id" : "023",
- "name" : "023",
"data" : [
[
"Perl",
@@ -421,10 +425,11 @@
"Blog",
12
]
- ]
+ ],
+ "id" : "023",
+ "name" : "023"
},
{
- "name" : "024",
"data" : [
[
"Perl",
@@ -439,9 +444,11 @@
11
]
],
- "id" : "024"
+ "id" : "024",
+ "name" : "024"
},
{
+ "name" : "025",
"data" : [
[
"Perl",
@@ -456,10 +463,10 @@
12
]
],
- "name" : "025",
"id" : "025"
},
{
+ "id" : "026",
"data" : [
[
"Perl",
@@ -474,8 +481,7 @@
10
]
],
- "name" : "026",
- "id" : "026"
+ "name" : "026"
},
{
"name" : "027",
@@ -496,7 +502,6 @@
"id" : "027"
},
{
- "name" : "028",
"data" : [
[
"Perl",
@@ -511,10 +516,11 @@
9
]
],
- "id" : "028"
+ "id" : "028",
+ "name" : "028"
},
{
- "name" : "029",
+ "id" : "029",
"data" : [
[
"Perl",
@@ -529,7 +535,7 @@
12
]
],
- "id" : "029"
+ "name" : "029"
},
{
"id" : "030",
@@ -550,8 +556,6 @@
"name" : "030"
},
{
- "id" : "031",
- "name" : "031",
"data" : [
[
"Perl",
@@ -565,10 +569,11 @@
"Blog",
9
]
- ]
+ ],
+ "id" : "031",
+ "name" : "031"
},
{
- "id" : "032",
"name" : "032",
"data" : [
[
@@ -583,11 +588,12 @@
"Blog",
10
]
- ]
+ ],
+ "id" : "032"
},
{
- "id" : "033",
"name" : "033",
+ "id" : "033",
"data" : [
[
"Perl",
@@ -604,6 +610,7 @@
]
},
{
+ "id" : "034",
"data" : [
[
"Perl",
@@ -618,8 +625,7 @@
11
]
],
- "name" : "034",
- "id" : "034"
+ "name" : "034"
},
{
"id" : "035",
@@ -640,6 +646,8 @@
"name" : "035"
},
{
+ "name" : "036",
+ "id" : "036",
"data" : [
[
"Perl",
@@ -653,12 +661,9 @@
"Blog",
11
]
- ],
- "name" : "036",
- "id" : "036"
+ ]
},