aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2021-12-15 11:57:13 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2021-12-15 11:57:13 +0000
commit0a84b8990b9a144bb82f6a8745e8315bbc0cd0fe (patch)
treefd373a3e5dc3909f53637db9df9d73bc40fb734e
parentd07cfa379e84c5ff6e68ddcbb443957f84132955 (diff)
downloadperlweeklychallenge-club-0a84b8990b9a144bb82f6a8745e8315bbc0cd0fe.tar.gz
perlweeklychallenge-club-0a84b8990b9a144bb82f6a8745e8315bbc0cd0fe.tar.bz2
perlweeklychallenge-club-0a84b8990b9a144bb82f6a8745e8315bbc0cd0fe.zip
- Added solutions by Laurent Rosenfeld.
-rw-r--r--challenge-143/laurent-rosenfeld/blog.txt1
-rw-r--r--challenge-143/laurent-rosenfeld/perl/ch-1.pl13
-rw-r--r--challenge-143/laurent-rosenfeld/perl/ch-2.pl33
-rw-r--r--challenge-143/laurent-rosenfeld/raku/ch-1.raku11
-rw-r--r--challenge-143/laurent-rosenfeld/raku/ch-2.raku17
-rw-r--r--stats/pwc-current.json161
-rw-r--r--stats/pwc-language-breakdown-summary.json58
-rw-r--r--stats/pwc-language-breakdown.json984
-rw-r--r--stats/pwc-leaders.json764
-rw-r--r--stats/pwc-summary-1-30.json44
-rw-r--r--stats/pwc-summary-121-150.json54
-rw-r--r--stats/pwc-summary-151-180.json44
-rw-r--r--stats/pwc-summary-181-210.json92
-rw-r--r--stats/pwc-summary-211-240.json46
-rw-r--r--stats/pwc-summary-241-270.json28
-rw-r--r--stats/pwc-summary-31-60.json118
-rw-r--r--stats/pwc-summary-61-90.json102
-rw-r--r--stats/pwc-summary-91-120.json102
-rw-r--r--stats/pwc-summary.json58
19 files changed, 1414 insertions, 1316 deletions
diff --git a/challenge-143/laurent-rosenfeld/blog.txt b/challenge-143/laurent-rosenfeld/blog.txt
new file mode 100644
index 0000000000..3b1d505950
--- /dev/null
+++ b/challenge-143/laurent-rosenfeld/blog.txt
@@ -0,0 +1 @@
+http://blogs.perl.org/users/laurent_r/2021/12/post.html
diff --git a/challenge-143/laurent-rosenfeld/perl/ch-1.pl b/challenge-143/laurent-rosenfeld/perl/ch-1.pl
new file mode 100644
index 0000000000..bb8edda515
--- /dev/null
+++ b/challenge-143/laurent-rosenfeld/perl/ch-1.pl
@@ -0,0 +1,13 @@
+use strict;
+use warnings;
+use feature "say";
+
+sub calc {
+ my $expr = shift;
+ return "Not a valid arithmetic expression" unless
+ $expr =~ /^[-\d\s+*()]+$/;
+ return eval $expr;
+}
+for my $test ("10 + 20 - 5", "(10 + 20 - 5) * 2", "7 + a", "6 * 7") {
+ say calc $test;
+}
diff --git a/challenge-143/laurent-rosenfeld/perl/ch-2.pl b/challenge-143/laurent-rosenfeld/perl/ch-2.pl
new file mode 100644
index 0000000000..4c0d53cc74
--- /dev/null
+++ b/challenge-143/laurent-rosenfeld/perl/ch-2.pl
@@ -0,0 +1,33 @@
+use strict;
+use warnings;
+use feature "say";
+
+sub cross {
+ my @nums = @_;
+ my @num_pairs;
+ for my $i (@nums) {
+ for my $j (@nums) {
+ next if $j > $i; # filter out duplicates such as [12, 3] and [3, 12]
+ push @num_pairs, [$i, $j];
+ }
+ }
+ return @num_pairs;
+}
+
+sub stealthy_nums {
+ my $n = shift;
+ my @divisors = grep {$n % $_ == 0} 1..$n;
+ my @div_pairs = grep { $_->[0] * $_->[1] == $n } cross @divisors;
+ for my $c (@div_pairs) {
+ for my $d (@div_pairs) {
+ return "@$c and @$d" if abs($c->[0] + $c->[1] - $d->[0] - $d->[1]) == 1;
+ }
+ }
+ return 0;
+}
+
+for my $test (qw <36 12 6>) {
+ my $result = stealthy_nums $test;
+ say "$test \t",
+ $result ? "1 -> $result" : 0;
+}
diff --git a/challenge-143/laurent-rosenfeld/raku/ch-1.raku b/challenge-143/laurent-rosenfeld/raku/ch-1.raku
new file mode 100644
index 0000000000..023b6d07d7
--- /dev/null
+++ b/challenge-143/laurent-rosenfeld/raku/ch-1.raku
@@ -0,0 +1,11 @@
+use v6;
+use MONKEY-SEE-NO-EVAL;
+
+sub calc (Str $expr) {
+ return "Not a valid arithmetic expression" unless
+ $expr ~~ /^<[-\d \s +*()]>+$/;
+ return EVAL $expr;
+}
+for "10 + 20 - 5", "(10 + 20 - 5) * 2", "7 + a", "6 * 7" -> $test {
+ say calc $test;
+}
diff --git a/challenge-143/laurent-rosenfeld/raku/ch-2.raku b/challenge-143/laurent-rosenfeld/raku/ch-2.raku
new file mode 100644
index 0000000000..8be44009c9
--- /dev/null
+++ b/challenge-143/laurent-rosenfeld/raku/ch-2.raku
@@ -0,0 +1,17 @@
+use v6;
+
+sub stealthy-nums (UInt $n) {
+ my @divisors = grep {$n %% $_}, 1..$n;
+ my @div-pairs = grep { $_[0] * $_[1] == $n }, (@divisors X @divisors);
+ # say @div-pairs;
+ for @div-pairs.combinations: 2 -> $c {
+ return $c if $c[0][0] + $c[0][1] - $c[1][0] - $c[1][1] == any(1, -1)
+ }
+ return False
+}
+
+for <36 12 6> -> $test {
+ my $result = stealthy-nums $test;
+ say "$test \t",
+ $result ?? "1 -> $result" !! 0;
+}
diff --git a/stats/pwc-current.json b/stats/pwc-current.json
index a01a3f87f8..eec2b4e797 100644
--- a/stats/pwc-current.json
+++ b/stats/pwc-current.json
@@ -1,9 +1,4 @@
{
- "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
- },
"series" : [
{
"name" : "The Weekly Challenge - 143",
@@ -20,96 +15,85 @@
"y" : 3
},
{
- "drilldown" : "E. Choroba",
"name" : "E. Choroba",
+ "drilldown" : "E. Choroba",
"y" : 2
},
{
+ "y" : 6,
"drilldown" : "Flavio Poletti",
- "name" : "Flavio Poletti",
- "y" : 6
+ "name" : "Flavio Poletti"
+ },
+ {
+ "name" : "Laurent Rosenfeld",
+ "drilldown" : "Laurent Rosenfeld",
+ "y" : 5
},
{
- "y" : 5,
"name" : "Luca Ferrari",
+ "y" : 5,
"drilldown" : "Luca Ferrari"
},
{
"drilldown" : "Mohammad S Anwar",
- "name" : "Mohammad S Anwar",
- "y" : 1
+ "y" : 1,
+ "name" : "Mohammad S Anwar"
},
{
- "y" : 1,
"drilldown" : "Olivier Delouya",
+ "y" : 1,
"name" : "Olivier Delouya"
},
{
- "y" : 2,
"name" : "Paulo Custodio",
+ "y" : 2,
"drilldown" : "Paulo Custodio"
},
{
+ "drilldown" : "Peter Campbell Smith",
"y" : 3,
- "name" : "Peter Campbell Smith",
- "drilldown" : "Peter Campbell Smith"
+ "name" : "Peter Campbell Smith"
},
{
- "y" : 2,
"name" : "Robert DiCicco",
+ "y" : 2,
"drilldown" : "Robert DiCicco"
},
{
- "y" : 4,
"drilldown" : "Roger Bell_West",
+ "y" : 4,
"name" : "Roger Bell_West"
},
{
- "drilldown" : "Ulrich Rieke",
"name" : "Ulrich Rieke",
+ "drilldown" : "Ulrich Rieke",
"y" : 2
},
{
+ "drilldown" : "W. Luis Mochan",
"y" : 3,
- "name" : "W. Luis Mochan",
- "drilldown" : "W. Luis Mochan"
+ "name" : "W. Luis Mochan"
}
]
}
],
- "chart" : {
- "type" : "column"
- },
- "xAxis" : {
- "type" : "category"
- },
- "plotOptions" : {
- "series" : {
- "borderWidth" : 0,
- "dataLabels" : {
- "enabled" : 1,
- "format" : "{point.y}"
- }
- }
- },
- "yAxis" : {
- "title" : {
- "text" : "Total Solutions"
- }
+ "title" : {
+ "text" : "The Weekly Challenge - 143"
},
"drilldown" : {
"series" : [
{
- "id" : "Alexander Pankoff",
+ "name" : "Alexander Pankoff",
"data" : [
[
"Perl",
2
]
],
- "name" : "Alexander Pankoff"
+ "id" : "Alexander Pankoff"
},
{
+ "id" : "Dave Jacoby",
"data" : [
[
"Perl",
@@ -120,8 +104,7 @@
1
]
],
- "name" : "Dave Jacoby",
- "id" : "Dave Jacoby"
+ "name" : "Dave Jacoby"
},
{
"data" : [
@@ -130,8 +113,8 @@
2
]
],
- "name" : "E. Choroba",
- "id" : "E. Choroba"
+ "id" : "E. Choroba",
+ "name" : "E. Choroba"
},
{
"data" : [
@@ -148,11 +131,30 @@
2
]
],
- "name" : "Flavio Poletti",
- "id" : "Flavio Poletti"
+ "id" : "Flavio Poletti",
+ "name" : "Flavio Poletti"
+ },
+ {
+ "name" : "Laurent Rosenfeld",
+ "id" : "Laurent Rosenfeld",
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Raku",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ]
},
{
"name" : "Luca Ferrari",
+ "id" : "Luca Ferrari",
"data" : [
[
"Raku",
@@ -162,8 +164,7 @@
"Blog",
3
]
- ],
- "id" : "Luca Ferrari"
+ ]
},
{
"name" : "Mohammad S Anwar",
@@ -176,27 +177,27 @@
"id" : "Mohammad S Anwar"
},
{
- "id" : "Olivier Delouya",
- "name" : "Olivier Delouya",
"data" : [
[
"Perl",
1
]
- ]
+ ],
+ "id" : "Olivier Delouya",
+ "name" : "Olivier Delouya"
},
{
+ "id" : "Paulo Custodio",
"data" : [
[
"Perl",
2
]
],
- "name" : "Paulo Custodio",
- "id" : "Paulo Custodio"
+ "name" : "Paulo Custodio"
},
{
- "id" : "Peter Campbell Smith",
+ "name" : "Peter Campbell Smith",
"data" : [
[
"Perl",
@@ -207,20 +208,20 @@
1
]
],
- "name" : "Peter Campbell Smith"
+ "id" : "Peter Campbell Smith"
},
{
- "id" : "Robert DiCicco",
- "name" : "Robert DiCicco",
"data" : [
[
"Perl",
2
]
- ]
+ ],
+ "id" : "Robert DiCicco",
+ "name" : "Robert DiCicco"
},
{
- "id" : "Roger Bell_West",
+ "name" : "Roger Bell_West",
"data" : [
[
"Perl",
@@ -231,9 +232,10 @@
2
]
],
- "name" : "Roger Bell_West"
+ "id" : "Roger Bell_West"
},
{
+ "name" : "Ulrich Rieke",
"id" : "Ulrich Rieke",
"data" : [
[
@@ -244,11 +246,10 @@
"Raku",
1
]
- ],
- "name" : "Ulrich Rieke"
+ ]
},
{
- "name" : "W. Luis Mochan",
+ "id" : "W. Luis Mochan",
"data" : [
[
"Perl",
@@ -259,17 +260,39 @@
1
]
],
- "id" : "W. Luis Mochan"
+ "name" : "W. Luis Mochan"
}
]
},
- "subtitle" : {
- "text" : "[Champions: 13] Last updated at 2021-12-15 10:22:00 GMT"
+ "chart" : {
+ "type" : "column"
+ },
+ "xAxis" : {
+ "type" : "category"
+ },
+ "plotOptions" : {
+ "series" : {
+ "dataLabels" : {
+ "enabled" : 1,
+ "format" : "{point.y}"
+ },
+ "borderWidth" : 0
+ }
+ },
+ "tooltip" : {
+ "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>",
+ "followPointer" : 1,
+ "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>"
},
"legend" : {
"enabled" : 0
},
- "title" : {
- "text" : "The Weekly Challenge - 143"
+ "subtitle" : {
+ "text" : "[Champions: 14] Last updated at 2021-12-15 11:52:47 GMT"
+ },
+ "yAxis" : {
+ "title" : {
+ "text" : "Total Solutions"
+ }
}
}
diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json
index 65964220b9..d58b8de874 100644
--- a/stats/pwc-language-breakdown-summary.json
+++ b/stats/pwc-language-breakdown-summary.json
@@ -1,53 +1,44 @@
{
- "yAxis" : {
- "min" : 0,
- "title" : {
- "text" : null
- }
- },
- "subtitle" : {
- "text" : "Last updated at 2021-12-15 10:22:00 GMT"
- },
- "legend" : {
- "enabled" : "false"
- },
"title" : {
"text" : "The Weekly Challenge Contributions [2019 - 2021]"
},
"series" : [
{
- "dataLabels" : {
- "rotation" : -90,
- "enabled" : "true",
- "y" : 10,
- "style" : {
- "fontFamily" : "Verdana, sans-serif",
- "fontSize" : "13px"
- },
- "color" : "#FFFFFF",
- "format" : "{point.y:.0f}",
- "align" : "right"
- },
- "name" : "Contributions",
"data" : [
[
"Blog",
- 2097
+ 2098
],
[
"Perl",
- 6875
+ 6877
],
[
"Raku",
- 4156
+ 4158
]
- ]
+ ],
+ "dataLabels" : {
+ "enabled" : "true",
+ "y" : 10,
+ "style" : {
+ "fontFamily" : "Verdana, sans-serif",
+ "fontSize" : "13px"
+ },
+ "rotation" : -90,
+ "align" : "right",
+ "format" : "{point.y:.0f}",
+ "color" : "#FFFFFF"
+ },
+ "name" : "Contributions"
}
],
"tooltip" : {
"pointFormat" : "<b>{point.y:.0f}</b>"
},
+ "legend" : {
+ "enabled" : "false"
+ },
"xAxis" : {
"type" : "category",
"labels" : {
@@ -59,5 +50,14 @@
},
"chart" : {
"type" : "column"
+ },
+ "yAxis" : {
+ "title" : {
+ "text" : null
+ },
+ "min" : 0
+ },
+ "subtitle" : {
+ "text" : "Last updated at 2021-12-15 11:52:47 GMT"
}
}
diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json
index 81c0f89dfd..ea7ab624f2 100644
--- a/stats/pwc-language-breakdown.json
+++ b/stats/pwc-language-breakdown.json
@@ -2,7 +2,6 @@
"drilldown" : {
"series" : [
{
- "name" : "001",
"data" : [
[
"Perl",
@@ -17,7 +16,8 @@
11
]
],
- "id" : "001"
+ "id" : "001",
+ "name" : "001"
},
{
"id" : "002",
@@ -38,8 +38,8 @@
"name" : "002"
},
{
- "id" : "003",
"name" : "003",
+ "id" : "003",
"data" : [
[
"Perl",
@@ -56,7 +56,7 @@
]
},
{
- "name" : "004",
+ "id" : "004",
"data" : [
[
"Perl",
@@ -71,7 +71,7 @@
10
]
],
- "id" : "004"
+ "name" : "004"
},
{
"id" : "005",
@@ -92,6 +92,7 @@
"name" : "005"
},
{
+ "name" : "006",
"id" : "006",
"data" : [
[
@@ -106,11 +107,10 @@
"Blog",
7
]
- ],
- "name" : "006"
+ ]
},
{
- "id" : "007",
+ "name" : "007",
"data" : [
[
"Perl",
@@ -125,9 +125,10 @@
10
]
],
- "name" : "007"
+ "id" : "007"
},
{
+ "name" : "008",
"id" : "008",
"data" : [
[
@@ -142,11 +143,10 @@
"Blog",
12
]
- ],
- "name" : "008"
+ ]
},
{
- "name" : "009",
+ "id" : "009",
"data" : [
[
"Perl",
@@ -161,7 +161,7 @@
13
]
],
- "id" : "009"
+ "name" : "009"
},
{
"data" : [
@@ -178,11 +178,10 @@
11
]
],
- "name" : "010",
- "id" : "010"
+ "id" : "010",
+ "name" : "010"
},
{
- "name" : "011",
"data" : [
[
"Perl",
@@ -197,9 +196,12 @@
10
]
],
- "id" : "011"
+ "id" : "011",
+ "name" : "011"
},
{
+ "name" : "012",
+ "id" : "012",
"data" : [
[
"Perl",
@@ -213,9 +215,7 @@
"Blog",
11
]
- ],
- "name" : "012",
- "id" : "012"
+ ]
},
{
"data" : [
@@ -232,8 +232,8 @@
13
]
],
- "name" : "013",
- "id" : "013"
+ "id" : "013",
+ "name" : "013"
},
{
"data" : [
@@ -250,11 +250,10 @@
15
]
],
- "name" : "014",
- "id" : "014"
+ "id" : "014",
+ "name" : "014"
},
{
- "id" : "015",
"name" : "015",
"data" : [
[
@@ -269,9 +268,11 @@
"Blog",
15
]
- ]
+ ],
+ "id" : "015"
},
{
+ "name" : "016",
"data" : [
[
"Perl",
@@ -286,11 +287,10 @@
12
]
],
- "name" : "016",
"id" : "016"
},
{
- "name" : "017",
+ "id" : "017",
"data" : [
[
"Perl",
@@ -305,11 +305,11 @@
12
]
],
- "id" : "017"
+ "name" : "017"
},
{
- "id" : "018",
"name" : "018",
+ "id" : "018",
"data" : [
[
"Perl",
@@ -340,11 +340,11 @@
13
]
],
- "name" : "019",
- "id" : "019"
+ "id" : "019",
+ "name" : "019"
},
{
- "id" : "020",
+ "name" : "020",
"data" : [
[
"Perl",
@@ -359,11 +359,10 @@
13
]
],
- "name" : "020"
+ "id" : "020"
},
{
"id" : "021",
- "name" : "021",
"data" : [
[
"Perl",
@@ -377,11 +376,11 @@
"Blog",
10
]
- ]
+ ],
+ "name" : "021"
},
{
"id" : "022",
- "name" : "022",
"data" : [
[
"Perl",
@@ -395,9 +394,11 @@
"Blog",
10
]
- ]
+ ],
+ "name" : "022"
},
{
+ "name" : "023",
"id" : "023",
"data" : [
[
@@ -412,8 +413,7 @@
"Blog",
12
]
- ],
- "name" : "023"
+ ]
},
{
"data" : [
@@ -430,8 +430,8 @@
11
]
],
- "name" : "024",
- "id" : "024"
+ "id" : "024",
+ "name" : "024"
},
{
"name" : "025",
@@ -452,7 +452,6 @@
"id" : "025"
},
{
- "id" : "026",
"data" : [
[
"Perl",
@@ -467,6 +466,7 @@
10
]
],
+ "id" : "026",
"name" : "026"
},
{
@@ -488,7 +488,6 @@
"id" : "027"
},
{
- "name" : "028",
"data" : [
[
"Perl",
@@ -503,9 +502,11 @@
9
]
],
- "id" : "028"
+ "id" : "028",
+ "name" : "028"
},
{
+ "id" : "029",
"data" : [
[
"Perl",
@@ -520,11 +521,9 @@
12
]
],
- "name" : "029",
- "id" : "029"
+ "name" : "029"
},
{
- "id" : "030",
"data" : [
[
"Perl",
@@ -539,10 +538,10 @@
10
]
],
+ "id" : "030",
"name" : "030"
},
{
- "id" : "031",
"name" : "031",
"data" : [
[
@@ -557,11 +556,12 @@
"Blog",
9
]
- ]
+ ],
+ "id" : "031"
},
{
- "id" : "032",
"name" : "032",
+ "id" : "032",
"data" : [
[
"Perl",
@@ -579,6 +579,7 @@
},
{
"name" : "033",
+ "id" : "033",
"data" : [
[
"Perl",
@@ -592,12 +593,10 @@
"Blog",
10
]
- ],
- "id" : "033"
+ ]
},
{
"id" : "034",
- "name" : "034",
"data" : [
[
"Perl",
@@ -611,7 +610,8 @@
"Blog",
11
]
- ]
+ ],
+ "name" : "034"
},
{
"name" : "035",
@@ -632,8 +632,6 @@
"id" : "035"
},
{
- "id" : "036",
- "name" : "036",
"data" : [
[
"Perl",
@@ -647,10 +645,12 @@
"Blog",
11
]
- ]
+ ],
+ "id" : "036",
+ "name" : "036"
},
{
- "name" : "037",
+ "id" : "037",
"data" : [
[
"Perl",
@@ -665,11 +665,9 @@
9
]
],
- "id" : "037"
+ "name" : "037"
},
{
- "id" : "038",
- "name" : "038",
"data" : [
[
"Perl",
@@ -683,9 +681,12 @@
"Blog",
12
]
- ]
+ ],
+ "id" : "038",
+ "name" : "038"
},
{
+ "name" : "039",
"id" : "039",
"data" : [
[
@@ -700,11 +701,10 @@
"Blog",
12
]
- ],
- "name" : "039"
+ ]
},
{
- "id" : "040",
+ "name" : "040",
"data" : [
[
"Perl",
@@ -719,11 +719,9 @@
10
]
],
- "name" : "040"
+ "id" : "040"
},
{
- "id" : "041",
- "name" : "041",
"data" : [
[
"Perl",
@@ -737,7 +735,9 @@
"Blog",
9
]
- ]
+ ],
+ "id" : "041",
+ "name" : "041"
},
{
"name" : "042",
@@ -758,8 +758,6 @@
"id" : "042"
},
{
- "id" : "043",
- "name" : "043",
"data" : [
[
"Perl",
@@ -773,11 +771,13 @@
"Blog",
11
]
- ]
+ ],
+ "id" : "043",
+ "name" : "043"
},
{
- "id" : "044",
"name" : "044",
+ "id" : "044",
"data" : [
[
"Perl",
@@ -794,6 +794,7 @@
]
},
{
+ "name" : "045",
"data" : [
[
"Perl",
@@ -808,10 +809,10 @@
11
]
],
- "name" : "045",
"id" : "045"
},
{
+ "name" : "046",
"data" : [
[
"Perl",
@@ -826,11 +827,10 @@
10
]
],
- "name" : "046",
"id" : "046"
},
{
- "id" : "047",
+ "name" : "047",
"data" : [
[
"Perl",
@@ -845,10 +845,9 @@
10
]
],
- "name" : "047"
+ "id" : "047"