aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2022-11-15 19:26:53 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2022-11-15 19:26:53 +0000
commitdc5f9b00fe9de4b70fccc96b088b5629e90233d1 (patch)
tree7d625a5eedfdf0bf4551c5aaf7e4371eabe820d1
parentd86f0a6e9d60b52336abab61bcf5bcb6aebc6240 (diff)
downloadperlweeklychallenge-club-dc5f9b00fe9de4b70fccc96b088b5629e90233d1.tar.gz
perlweeklychallenge-club-dc5f9b00fe9de4b70fccc96b088b5629e90233d1.tar.bz2
perlweeklychallenge-club-dc5f9b00fe9de4b70fccc96b088b5629e90233d1.zip
- Added solutions by Laurent Rosenfeld.
-rw-r--r--challenge-191/laurent-rosenfeld/blog.txt1
-rw-r--r--challenge-191/laurent-rosenfeld/perl/ch-1.pl12
-rw-r--r--challenge-191/laurent-rosenfeld/perl/ch-2.pl38
-rw-r--r--challenge-191/laurent-rosenfeld/raku/ch-1.raku7
-rw-r--r--challenge-191/laurent-rosenfeld/raku/ch-2.raku19
-rw-r--r--stats/pwc-current.json225
-rw-r--r--stats/pwc-language-breakdown-summary.json86
-rw-r--r--stats/pwc-language-breakdown.json1272
-rw-r--r--stats/pwc-leaders.json402
-rw-r--r--stats/pwc-summary-1-30.json32
-rw-r--r--stats/pwc-summary-121-150.json108
-rw-r--r--stats/pwc-summary-151-180.json100
-rw-r--r--stats/pwc-summary-181-210.json112
-rw-r--r--stats/pwc-summary-211-240.json34
-rw-r--r--stats/pwc-summary-241-270.json112
-rw-r--r--stats/pwc-summary-271-300.json66
-rw-r--r--stats/pwc-summary-31-60.json108
-rw-r--r--stats/pwc-summary-61-90.json98
-rw-r--r--stats/pwc-summary-91-120.json42
-rw-r--r--stats/pwc-summary.json38
20 files changed, 1506 insertions, 1406 deletions
diff --git a/challenge-191/laurent-rosenfeld/blog.txt b/challenge-191/laurent-rosenfeld/blog.txt
new file mode 100644
index 0000000000..df50399e52
--- /dev/null
+++ b/challenge-191/laurent-rosenfeld/blog.txt
@@ -0,0 +1 @@
+http://blogs.perl.org/users/laurent_r/2022/11/perl-weekly-challenge-191-twice-largest-and-cute-list.html
diff --git a/challenge-191/laurent-rosenfeld/perl/ch-1.pl b/challenge-191/laurent-rosenfeld/perl/ch-1.pl
new file mode 100644
index 0000000000..a729e70a6b
--- /dev/null
+++ b/challenge-191/laurent-rosenfeld/perl/ch-1.pl
@@ -0,0 +1,12 @@
+use strict;
+use warnings;
+use feature qw/say/;
+
+sub is_twice_as_large {
+ my @sorted = sort { $b <=> $a } @_;
+ return $sorted[0] >= 2 * $sorted[1];
+}
+for my $test ( [<1 2 3 4>], [<1 2 0 5>],
+ [<2 6 3 1>], [<4 5 2 3>] ) {
+ say "@$test -> ", is_twice_as_large(@$test) ? 1 : -1;
+}
diff --git a/challenge-191/laurent-rosenfeld/perl/ch-2.pl b/challenge-191/laurent-rosenfeld/perl/ch-2.pl
new file mode 100644
index 0000000000..1d9b833b9c
--- /dev/null
+++ b/challenge-191/laurent-rosenfeld/perl/ch-2.pl
@@ -0,0 +1,38 @@
+use strict;
+use warnings;
+use feature qw/say/;
+
+my @permutations;
+
+sub is_cute {
+ my @new = (0, @_);
+ for my $i (1.. scalar @_) {
+ return 0 if $i % $new[$i] and $new[$i] % $i;
+ }
+ return 1;
+}
+
+sub permute {
+ my ($done, $left) = @_;
+ if (scalar @$left == 0) {
+ push @permutations, $done;
+ return;
+ }
+ my @left = @$left;
+ permute([ @$done, $left[$_]], [@left[0..$_-1], @left[$_+1..$#left]]) for 0..$#left;
+}
+
+sub count_cute {
+ my $k = shift;
+ my $count = 0;
+ @permutations = ();
+ permute([], [1..$k]);
+ for my $perm (@permutations) {
+ $count++ if is_cute @$perm;
+ }
+ return $count;
+}
+
+for my $j (1..10) {
+ say "$j -> ", count_cute $j;
+}
diff --git a/challenge-191/laurent-rosenfeld/raku/ch-1.raku b/challenge-191/laurent-rosenfeld/raku/ch-1.raku
new file mode 100644
index 0000000000..fb321abc5a
--- /dev/null
+++ b/challenge-191/laurent-rosenfeld/raku/ch-1.raku
@@ -0,0 +1,7 @@
+sub is-twice-as-large (@input) {
+ my @sorted = reverse sort @input;
+ return @sorted[0] >= 2 * @sorted[1];
+}
+for <1 2 3 4>, <1 2 0 5>, <2 6 3 1>, <4 5 2 3> -> @test {
+ say @test, " -> ", is-twice-as-large(@test) ?? 1 !! -1;
+}
diff --git a/challenge-191/laurent-rosenfeld/raku/ch-2.raku b/challenge-191/laurent-rosenfeld/raku/ch-2.raku
new file mode 100644
index 0000000000..2431e4a0e6
--- /dev/null
+++ b/challenge-191/laurent-rosenfeld/raku/ch-2.raku
@@ -0,0 +1,19 @@
+sub is-cute (@list) {
+ my @new = (0, @list).flat;
+ for 1..@list.elems -> $i {
+ return False unless $i %% @new[$i] or @new[$i] %% $i;
+ }
+ return True;
+}
+
+sub count-cute ($k) {
+ my $count = 0;
+ for (1..$k).permutations -> @perm {
+ $count++ if is-cute @perm;
+ }
+ return $count;
+}
+
+for 1..10 -> $j {
+ say "$j -> ", count-cute $j;
+}
diff --git a/stats/pwc-current.json b/stats/pwc-current.json
index 8a0d84c48d..26d27631b7 100644
--- a/stats/pwc-current.json
+++ b/stats/pwc-current.json
@@ -2,44 +2,132 @@
"xAxis" : {
"type" : "category"
},
- "legend" : {
- "enabled" : 0
+ "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/>"
+ },
+ "title" : {
+ "text" : "The Weekly Challenge - 191"
},
"subtitle" : {
- "text" : "[Champions: 11] Last updated at 2022-11-15 08:17:53 GMT"
+ "text" : "[Champions: 12] Last updated at 2022-11-15 19:18:32 GMT"
},
- "yAxis" : {
- "title" : {
- "text" : "Total Solutions"
+ "series" : [
+ {
+ "data" : [
+ {
+ "y" : 2,
+ "drilldown" : "Feng Chang",
+ "name" : "Feng Chang"
+ },
+ {
+ "drilldown" : "Humberto Massa",
+ "name" : "Humberto Massa",
+ "y" : 2
+ },
+ {
+ "y" : 5,
+ "name" : "Laurent Rosenfeld",
+ "drilldown" : "Laurent Rosenfeld"
+ },
+ {
+ "name" : "Luca Ferrari",
+ "drilldown" : "Luca Ferrari",
+ "y" : 8
+ },
+ {
+ "y" : 2,
+ "name" : "Niels van Dijke",
+ "drilldown" : "Niels van Dijke"
+ },
+ {
+ "drilldown" : "Peter Campbell Smith",
+ "name" : "Peter Campbell Smith",
+ "y" : 3
+ },
+ {
+ "name" : "Robert DiCicco",
+ "drilldown" : "Robert DiCicco",
+ "y" : 2
+ },
+ {
+ "y" : 4,
+ "name" : "Roger Bell_West",
+ "drilldown" : "Roger Bell_West"
+ },
+ {
+ "name" : "Simon Proctor",
+ "drilldown" : "Simon Proctor",
+ "y" : 2
+ },
+ {
+ "y" : 2,
+ "name" : "Tim Potapov",
+ "drilldown" : "Tim Potapov"
+ },
+ {
+ "y" : 4,
+ "name" : "Ulrich Rieke",
+ "drilldown" : "Ulrich Rieke"
+ },
+ {
+ "drilldown" : "W. Luis Mochan",
+ "name" : "W. Luis Mochan",
+ "y" : 3
+ }
+ ],
+ "name" : "The Weekly Challenge - 191",
+ "colorByPoint" : 1
}
+ ],
+ "chart" : {
+ "type" : "column"
},
- "title" : {
- "text" : "The Weekly Challenge - 191"
+ "legend" : {
+ "enabled" : 0
},
"drilldown" : {
"series" : [
{
"name" : "Feng Chang",
- "id" : "Feng Chang",
"data" : [
[
"Raku",
2
]
- ]
+ ],
+ "id" : "Feng Chang"
},
{
- "id" : "Humberto Massa",
+ "name" : "Humberto Massa",
"data" : [
[
"Raku",
2
]
],
- "name" : "Humberto Massa"
+ "id" : "Humberto Massa"
+ },
+ {
+ "id" : "Laurent Rosenfeld",
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Raku",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "name" : "Laurent Rosenfeld"
},
{
- "name" : "Luca Ferrari",
"id" : "Luca Ferrari",
"data" : [
[
@@ -50,7 +138,8 @@
"Blog",
6
]
- ]
+ ],
+ "name" : "Luca Ferrari"
},
{
"data" : [
@@ -59,11 +148,12 @@
2
]
],
- "id" : "Niels van Dijke",
- "name" : "Niels van Dijke"
+ "name" : "Niels van Dijke",
+ "id" : "Niels van Dijke"
},
{
"id" : "Peter Campbell Smith",
+ "name" : "Peter Campbell Smith",
"data" : [
[
"Perl",
@@ -73,10 +163,10 @@
"Blog",
1
]
- ],
- "name" : "Peter Campbell Smith"
+ ]
},
{
+ "id" : "Robert DiCicco",
"name" : "Robert DiCicco",
"data" : [
[
@@ -87,11 +177,9 @@
"Raku",
1
]
- ],
- "id" : "Robert DiCicco"
+ ]
},
{
- "name" : "Roger Bell_West",
"data" : [
[
"Perl",
@@ -102,29 +190,32 @@
2
]
],
+ "name" : "Roger Bell_West",
"id" : "Roger Bell_West"
},
{
- "id" : "Simon Proctor",
+ "name" : "Simon Proctor",
"data" : [
[
"Raku",
2
]
],
- "name" : "Simon Proctor"
+ "id" : "Simon Proctor"
},
{
+ "id" : "Tim Potapov",
"name" : "Tim Potapov",
"data" : [
[
"Perl",
2
]
- ],
- "id" : "Tim Potapov"
+ ]
},
{
+ "id" : "Ulrich Rieke",
+ "name" : "Ulrich Rieke",
"data" : [
[
"Perl",
@@ -134,12 +225,9 @@
"Raku",
2
]
- ],
- "id" : "Ulrich Rieke",
- "name" : "Ulrich Rieke"
+ ]
},
{
- "id" : "W. Luis Mochan",
"data" : [
[
"Perl",
@@ -150,88 +238,23 @@
1
]
],
- "name" : "W. Luis Mochan"
+ "name" : "W. Luis Mochan",
+ "id" : "W. Luis Mochan"
}
]
},
- "chart" : {
- "type" : "column"
- },
- "series" : [
- {
- "colorByPoint" : 1,
- "data" : [
- {
- "drilldown" : "Feng Chang",
- "y" : 2,
- "name" : "Feng Chang"
- },
- {
- "drilldown" : "Humberto Massa",
- "y" : 2,
- "name" : "Humberto Massa"
- },
- {
- "drilldown" : "Luca Ferrari",
- "name" : "Luca Ferrari",
- "y" : 8
- },
- {
- "drilldown" : "Niels van Dijke",
- "y" : 2,
- "name" : "Niels van Dijke"
- },
- {
- "name" : "Peter Campbell Smith",
- "y" : 3,
- "drilldown" : "Peter Campbell Smith"
- },
- {
- "drilldown" : "Robert DiCicco",
- "y" : 2,
- "name" : "Robert DiCicco"
- },
- {
- "drilldown" : "Roger Bell_West",
- "y" : 4,
- "name" : "Roger Bell_West"
- },
- {
- "drilldown" : "Simon Proctor",
- "name" : "Simon Proctor",
- "y" : 2
- },
- {
- "name" : "Tim Potapov",
- "y" : 2,
- "drilldown" : "Tim Potapov"
- },
- {
- "drilldown" : "Ulrich Rieke",
- "name" : "Ulrich Rieke",
- "y" : 4
- },
- {
- "y" : 3,
- "name" : "W. Luis Mochan",
- "drilldown" : "W. Luis Mochan"
- }
- ],
- "name" : "The Weekly Challenge - 191"
+ "yAxis" : {
+ "title" : {
+ "text" : "Total Solutions"
}
- ],
- "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/>"
},
"plotOptions" : {
"series" : {
- "borderWidth" : 0,
"dataLabels" : {
"enabled" : 1,
"format" : "{point.y}"
- }
+ },
+ "borderWidth" : 0
}
}
}
diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json
index 710eceae5f..45de0ac0bc 100644
--- a/stats/pwc-language-breakdown-summary.json
+++ b/stats/pwc-language-breakdown-summary.json
@@ -1,63 +1,63 @@
{
- "title" : {
- "text" : "The Weekly Challenge Contributions [2019 - 2022]"
- },
- "yAxis" : {
- "min" : 0,
- "title" : {
- "text" : null
- }
- },
- "subtitle" : {
- "text" : "Last updated at 2022-11-15 08:17:53 GMT"
- },
- "legend" : {
- "enabled" : "false"
- },
- "xAxis" : {
- "labels" : {
- "style" : {
- "fontFamily" : "Verdana, sans-serif",
- "fontSize" : "13px"
- }
- },
- "type" : "category"
- },
- "tooltip" : {
- "pointFormat" : "<b>{point.y:.0f}</b>"
- },
- "chart" : {
- "type" : "column"
- },
"series" : [
{
+ "name" : "Contributions",
"data" : [
[
"Blog",
- 3022
+ 3023
],
[
"Perl",
- 9324
+ 9326
],
[
"Raku",
- 5599
+ 5601
]
],
"dataLabels" : {
- "style" : {
- "fontFamily" : "Verdana, sans-serif",
- "fontSize" : "13px"
- },
- "enabled" : "true",
- "align" : "right",
"y" : 10,
+ "format" : "{point.y:.0f}",
+ "enabled" : "true",
"color" : "#FFFFFF",
"rotation" : -90,
- "format" : "{point.y:.0f}"
- },
- "name" : "Contributions"
+ "align" : "right",
+ "style" : {
+ "fontSize" : "13px",
+ "fontFamily" : "Verdana, sans-serif"
+ }
+ }
+ }
+ ],
+ "subtitle" : {
+ "text" : "Last updated at 2022-11-15 19:18:32 GMT"
+ },
+ "legend" : {
+ "enabled" : "false"
+ },
+ "chart" : {
+ "type" : "column"
+ },
+ "xAxis" : {
+ "type" : "category",
+ "labels" : {
+ "style" : {
+ "fontSize" : "13px",
+ "fontFamily" : "Verdana, sans-serif"
+ }
}
- ]
+ },
+ "tooltip" : {
+ "pointFormat" : "<b>{point.y:.0f}</b>"
+ },
+ "title" : {
+ "text" : "The Weekly Challenge Contributions [2019 - 2022]"
+ },
+ "yAxis" : {
+ "title" : {
+ "text" : null
+ },
+ "min" : 0
+ }
}
diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json
index 1c5ec2b41d..61bb270e92 100644
--- a/stats/pwc-language-breakdown.json
+++ b/stats/pwc-language-breakdown.json
@@ -1,25 +1,16 @@
{
- "xAxis" : {
- "type" : "category"
- },
- "legend" : {
- "enabled" : "false"
- },
- "subtitle" : {
- "text" : "Click the columns to drilldown the language breakdown. Last updated at 2022-11-15 08:17:53 GMT"
- },
- "yAxis" : {
- "title" : {
- "text" : "Total Solutions"
+ "plotOptions" : {
+ "series" : {
+ "dataLabels" : {
+ "format" : "{point.y}",
+ "enabled" : 1
+ },
+ "borderWidth" : 0
}
},
- "title" : {
- "text" : "The Weekly Challenge Language"
- },
"drilldown" : {
"series" : [
{
- "name" : "001",
"id" : "001",
"data" : [
[
@@ -34,10 +25,10 @@
"Blog",
11
]
- ]
+ ],
+ "name" : "001"
},
{
- "name" : "002",
"id" : "002",
"data" : [
[
@@ -52,10 +43,10 @@
"Blog",
10
]
- ]
+ ],
+ "name" : "002"
},
{
- "name" : "003",
"id" : "003",
"data" : [
[
@@ -70,9 +61,11 @@
"Blog",
9
]
- ]
+ ],
+ "name" : "003"
},
{
+ "id" : "004",
"data" : [
[
"Perl",
@@ -87,10 +80,10 @@
10
]
],
- "id" : "004",
"name" : "004"
},
{
+ "id" : "005",
"name" : "005",
"data" : [
[
@@ -105,10 +98,11 @@
"Blog",
12
]
- ],
- "id" : "005"
+ ]
},
{
+ "id" : "006",
+ "name" : "006",
"data" : [
[
"Perl",
@@ -122,11 +116,10 @@
"Blog",
7
]
- ],
- "id" : "006",
- "name" : "006"
+ ]
},
{
+ "id" : "007",
"name" : "007",
"data" : [
[
@@ -141,11 +134,11 @@
"Blog",
10
]
- ],
- "id" : "007"
+ ]
},
{
"id" : "008",
+ "name" : "008",
"data" : [
[
"Perl",
@@ -159,11 +152,10 @@
"Blog",
12
]
- ],
- "name" : "008"
+ ]
},
{
- "name" : "009",
+ "id" : "009",
"data" : [
[
"Perl",
@@ -178,10 +170,9 @@
13
]
],
- "id" : "009"
+ "name" : "009"
},
{
- "id" : "010",
"data" : [
[
"Perl",
@@ -196,10 +187,10 @@
11
]
],
- "name" : "010"
+ "name" : "010",
+ "id" : "010"
},
{
- "name" : "011",
"id" : "011",
"data" : [
[
@@ -214,11 +205,12 @@
"Blog",
10
]
- ]
+ ],
+ "name" : "011"
},
{
- "name" : "012",
"id" : "012",
+ "name" : "012",
"data" : [
[
"Perl",
@@ -235,7 +227,6 @@
]
},
{
- "id" : "013",
"data" : [
[
"Perl",
@@ -250,9 +241,12 @@
13
]
],
- "name" : "013"
+ "name" : "013",
+ "id" : "013"
},
{
+ "id" : "014",
+ "name" : "014",
"data" : [
[
"Perl",
@@ -266,12 +260,9 @@
"Blog",
15
]
- ],
- "id" : "014",
- "name" : "014"
+ ]
},
{
- "name" : "015",
"id" : "015",
"data" : [
[
@@ -286,10 +277,12 @@
"Blog",
15
]
- ]
+ ],
+ "name" : "015"
},
{
"id" : "016",
+ "name" : "016",
"data" : [
[
"Perl",
@@ -303,10 +296,10 @@
"Blog",
12
]
- ],
- "name" : "016"
+ ]
},
{
+ "id" : "017",
"data" : [
[
"Perl",
@@ -321,12 +314,9 @@
12
]
],
- "id" : "017",
"name" : "017"
},
{
- "name" : "018",
- "id" : "018",
"data" : [
[
"Perl",
@@ -340,11 +330,13 @@
"Blog",
14
]
- ]
+ ],
+ "name" : "018",
+ "id" : "018"
},
{
- "name" : "019",
"id" : "019",
+ "name" : "019",
"data" : [
[
"Perl",
@@ -361,6 +353,7 @@
]
},
{
+ "id" : "020",
"data" : [
[
"Perl",
@@ -375,11 +368,9 @@
13
]
],
- "id" : "020",
"name" : "020"
},
{
- "name" : "021",
"data" : [
[
"Perl",
@@ -394,6 +385,7 @@
10
]
],
+ "name" : "021",
"id" : "021"
},
{
@@ -411,11 +403,11 @@
10
]
],
- "id" : "022",
- "name" : "022"
+ "name" : "022",
+ "id" : "022"
},
{
- "name" : "023",
+ "id" : "023",
"data" : [
[
"Perl",
@@ -430,10 +422,9 @@
12
]
],
- "id" : "023"
+ "name" : "023"
},
{
- "name" : "024",
"data" : [
[
"Perl",
@@ -448,9 +439,11 @@
11
]
],
+ "name" : "024",
"id" : "024"
},
{
+ "name" : "025",
"data" : [
[
"Perl",
@@ -465,11 +458,11 @@
12
]
],
- "id" : "025",
- "name" : "025"
+ "id" : "025"
},
{
"id" : "026",
+ "name" : "026",
"data" : [
[
"Perl",
@@ -483,8 +476,7 @@
"Blog",
10
]
- ],
- "name" : "026"
+ ]
},
{
"name" : "027",
@@ -505,6 +497,7 @@
"id" : "027"
},
{
+ "id" : "028",
"data" : [
[
"Perl",
@@ -519,11 +512,9 @@
9
]
],
- "id" : "028",
"name" : "028"
},
{
- "name" : "029",
"data" : [
[
"Perl",
@@ -538,10 +529,12 @@
12
]
],
+ "name" : "029",
"id" : "029"
},
{
"id" : "030",
+ "name" : "030",
"data" : [
[
"Perl",
@@ -555,11 +548,11 @@
"Blog",
10
]
- ],
- "name" : "030"
+ ]
},
{
"id" : "031",
+ "name" : "031",
"data" : [
[
"Perl",
@@ -573,10 +566,10 @@
"Blog",
9
]
- ],
- "name" : "031"
+ ]
},
{
+ "id" : "032",
"name" : "032",
"data" : [
[
@@ -591,8 +584,7 @@
"Blog",
10
]
- ],
- "id" : "032"
+ ]
},
{
"id" : "033",
@@ -613,7 +605,7 @@
"name" : "033"
},
{
- "name" : "034",
+ "id" : "034",
"data" : [
[
"Perl",
@@ -628,9 +620,10 @@
11
]
],
- "id" : "034"
+ "name" : "034"
},
{
+ "id" : "035",
"data" : [
[
"Perl",
@@ -645,12 +638,9 @@
9
]
],
- "id" : "035",
"name" : "035"
},
{
- "name" : "036",
- "id" : "036",
"data" : [
[
"Perl",
@@ -664,10 +654,13 @@
"Blog",
11
]
- ]
+ ],
+ "name" : "036",
+ "id" : "036"
},
{
"id" : "037",
+ "name" : "037",
"data" : [
[
"Perl",
@@ -681,11 +674,11 @@
"Blog",
9
]
- ],
- "name" : "037"
+ ]
},
{
"id" : "038",
+ "name" : "038",
"data" : [
[
"Perl",
@@ -699,10 +692,10 @@