diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-05-20 19:32:04 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-05-20 19:32:04 +0100 |
| commit | 914fc5dec5a114e33e1acc3504f38e85654daf9e (patch) | |
| tree | 945adfb734ed70fa977a3d10548e3da5d2a08d8a | |
| parent | daab3b587a9003f5023908187e34f139ad3f41af (diff) | |
| download | perlweeklychallenge-club-914fc5dec5a114e33e1acc3504f38e85654daf9e.tar.gz perlweeklychallenge-club-914fc5dec5a114e33e1acc3504f38e85654daf9e.tar.bz2 perlweeklychallenge-club-914fc5dec5a114e33e1acc3504f38e85654daf9e.zip | |
- Added solutions by Laurent Rosenfeld.
| -rw-r--r-- | challenge-165/laurent-rosenfeld/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-165/laurent-rosenfeld/perl/ch-2.pl | 35 | ||||
| -rw-r--r-- | challenge-165/laurent-rosenfeld/raku/ch-2.raku | 30 | ||||
| -rw-r--r-- | stats/pwc-current.json | 251 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 74 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 1162 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 414 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 94 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 102 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 94 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 96 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 26 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 50 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 52 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 34 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 44 |
17 files changed, 1344 insertions, 1255 deletions
diff --git a/challenge-165/laurent-rosenfeld/blog.txt b/challenge-165/laurent-rosenfeld/blog.txt new file mode 100644 index 0000000000..db587de7db --- /dev/null +++ b/challenge-165/laurent-rosenfeld/blog.txt @@ -0,0 +1 @@ +http://blogs.perl.org/users/laurent_r/2022/05/perl-weekly-challenge-165-line-of-best-fit.html diff --git a/challenge-165/laurent-rosenfeld/perl/ch-2.pl b/challenge-165/laurent-rosenfeld/perl/ch-2.pl new file mode 100644 index 0000000000..850173faca --- /dev/null +++ b/challenge-165/laurent-rosenfeld/perl/ch-2.pl @@ -0,0 +1,35 @@ +use strict; +use warnings; +use feature "say"; + +my $input = + '333,129 39,189 140,156 292,134 393,52 160,166 362,122 13,193 + 341,104 320,113 109,177 203,152 343,100 225,110 23,186 282,102 + 284,98 205,133 297,114 292,126 339,112 327,79 253,136 61,169 + 128,176 346,72 316,103 124,162 65,181 159,137 212,116 337,86 + 215,136 153,137 390,104 100,180 76,188 77,181 69,195 92,186 + 275,96 250,147 34,174 213,134 186,129 189,154 361,82 363,89'; + +# $input = '1,0 2,1 3,2 4,3'; # test with a negative intercept + +my @points = map { [split /,/, $_] } split /\s+/, $input; +my ($sl, $inter) = lsm(@points); +say "Slope: $sl, intercept = $inter"; +my $sign = $inter < 0 ? '-' : '+'; +printf "The equation of the line of best fit is: y = %.2f x %s %.2f \n", $sl, $sign, abs $inter; + +sub lsm { + my @points = @_; + my ($s_x, $s_y, $s_xy, $s_x2) = (0, 0, 0, 0); + for my $point (@points) { + my ($x, $y) = ($point->[0], $point->[1]); + $s_x += $x; + $s_y += $y; + $s_xy += $x * $y; + $s_x2 += $x ** 2; + } + my $n = scalar @points; + my $slope = ($n * $s_xy - $s_x * $s_y) / ($n * $s_x2 - $s_x ** 2); + my $intercept = ($s_y - $slope * $s_x) / $n; + return $slope, $intercept; +} diff --git a/challenge-165/laurent-rosenfeld/raku/ch-2.raku b/challenge-165/laurent-rosenfeld/raku/ch-2.raku new file mode 100644 index 0000000000..10cddb8743 --- /dev/null +++ b/challenge-165/laurent-rosenfeld/raku/ch-2.raku @@ -0,0 +1,30 @@ +my $input = + '333,129 39,189 140,156 292,134 393,52 160,166 362,122 13,193 + 341,104 320,113 109,177 203,152 343,100 225,110 23,186 282,102 + 284,98 205,133 297,114 292,126 339,112 327,79 253,136 61,169 + 128,176 346,72 316,103 124,162 65,181 159,137 212,116 337,86 + 215,136 153,137 390,104 100,180 76,188 77,181 69,195 92,186 + 275,96 250,147 34,174 213,134 186,129 189,154 361,82 363,89'; + +# $input = '1,0 2,1 3,2 4,3'; # test with a negative intercept + +my @points = $input.split(/\s+/)ยป.split(/','/); +my ($slope, $intercept) = lsm(@points); +say "Slope: $slope, intercept = $intercept"; +my $sign = $intercept < 0 ?? '-' !! '+'; +printf "The equation of the line of best fit is: y = %.2f x %s %.2f \n", $slope, $sign, $intercept.abs; + +sub lsm (@points) { + my ($s-x, $s-y, $s-xy, $s-x2) = 0 xx 4; + for @points -> $point { + my ($x, $y) = $point[0, 1]; + $s-x += $x; + $s-y += $y; + $s-xy += $x * $y; + $s-x2 += $x ** 2; + } + my $n = @points.elems; + my $slope = ($n * $s-xy - $s-x * $s-y) / ($n * $s-x2 - $s-x ** 2); + my $intercept = ($s-y - $slope * $s-x) / $n; + return $slope, $intercept; +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 30b1830607..2a957e10a2 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,23 +1,106 @@ { - "chart" : { - "type" : "column" + "subtitle" : { + "text" : "[Champions: 13] Last updated at 2022-05-20 18:29:55 GMT" }, - "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/>" }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + } + } + }, + "xAxis" : { + "type" : "category" + }, + "series" : [ + { + "colorByPoint" : 1, + "name" : "The Weekly Challenge - 165", + "data" : [ + { + "name" : "Cheok-Yin Fung", + "drilldown" : "Cheok-Yin Fung", + "y" : 3 + }, + { + "y" : 6, + "name" : "Flavio Poletti", + "drilldown" : "Flavio Poletti" + }, + { + "y" : 3, + "drilldown" : "James Smith", + "name" : "James Smith" + }, + { + "y" : 2, + "drilldown" : "Jorg Sommrey", + "name" : "Jorg Sommrey" + }, + { + "y" : 2, + "drilldown" : "Julien Fiegehenn", + "name" : "Julien Fiegehenn" + }, + { + "y" : 3, + "name" : "Laurent Rosenfeld", + "drilldown" : "Laurent Rosenfeld" + }, + { + "y" : 8, + "name" : "Luca Ferrari", + "drilldown" : "Luca Ferrari" + }, + { + "name" : "Mark Anderson", + "drilldown" : "Mark Anderson", + "y" : 2 + }, + { + "drilldown" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith", + "y" : 3 + }, + { + "y" : 2, + "drilldown" : "Robert Ransbottom", + "name" : "Robert Ransbottom" + }, + { + "name" : "Roger Bell_West", + "drilldown" : "Roger Bell_West", + "y" : 5 + }, + { + "y" : 3, + "drilldown" : "Ryan Thompson", + "name" : "Ryan Thompson" + }, + { + "name" : "Ulrich Rieke", + "drilldown" : "Ulrich Rieke", + "y" : 2 + } + ] + } + ], "title" : { "text" : "The Weekly Challenge - 165" }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } + "chart" : { + "type" : "column" }, "drilldown" : { "series" : [ { - "name" : "Cheok-Yin Fung", - "id" : "Cheok-Yin Fung", "data" : [ [ "Perl", @@ -27,9 +110,13 @@ "Blog", 1 ] - ] + ], + "name" : "Cheok-Yin Fung", + "id" : "Cheok-Yin Fung" }, { + "id" : "Flavio Poletti", + "name" : "Flavio Poletti", "data" : [ [ "Perl", @@ -43,9 +130,7 @@ "Blog", 2 ] - ], - "id" : "Flavio Poletti", - "name" : "Flavio Poletti" + ] }, { "data" : [ @@ -58,8 +143,8 @@ 1 ] ], - "id" : "James Smith", - "name" : "James Smith" + "name" : "James Smith", + "id" : "James Smith" }, { "data" : [ @@ -72,18 +157,34 @@ "id" : "Jorg Sommrey" }, { + "id" : "Julien Fiegehenn", "data" : [ [ "Perl", 2 ] ], - "id" : "Julien Fiegehenn", "name" : "Julien Fiegehenn" }, { - "name" : "Luca Ferrari", - "id" : "Luca Ferrari", + "id" : "Laurent Rosenfeld", + "data" : [ + [ + "Perl", + 1 + ], + [ + "Raku", + 1 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Laurent Rosenfeld" + }, + { "data" : [ [ "Raku", @@ -93,7 +194,9 @@ "Blog", 6 ] - ] + ], + "name" : "Luca Ferrari", + "id" : "Luca Ferrari" }, { "data" : [ @@ -102,8 +205,8 @@ 2 ] ], - "id" : "Mark Anderson", - "name" : "Mark Anderson" + "name" : "Mark Anderson", + "id" : "Mark Anderson" }, { "data" : [ @@ -120,18 +223,16 @@ "id" : "Peter Campbell Smith" }, { + "id" : "Robert Ransbottom", "data" : [ [ "Raku", 2 ] ], - "id" : "Robert Ransbottom", "name" : "Robert Ransbottom" }, { - "name" : "Roger Bell_West", - "id" : "Roger Bell_West", "data" : [ [ "Perl", @@ -145,10 +246,11 @@ "Blog", 1 ] - ] + ], + "name" : "Roger Bell_West", + "id" : "Roger Bell_West" }, { - "name" : "Ryan Thompson", "id" : "Ryan Thompson", "data" : [ [ @@ -159,106 +261,27 @@ "Blog", 1 ] - ] + ], + "name" : "Ryan Thompson" }, { + "id" : "Ulrich Rieke", "data" : [ [ "Perl", 2 ] ], - "id" : "Ulrich Rieke", "name" : "Ulrich Rieke" } ] }, - "plotOptions" : { - "series" : { - "borderWidth" : 0, - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - } - } - }, - "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 }, - "series" : [ - { - "data" : [ - { - "drilldown" : "Cheok-Yin Fung", - "y" : 3, - "name" : "Cheok-Yin Fung" - }, - { - "drilldown" : "Flavio Poletti", - "y" : 6, - "name" : "Flavio Poletti" - }, - { - "name" : "James Smith", - "drilldown" : "James Smith", - "y" : 3 - }, - { - "y" : 2, - "drilldown" : "Jorg Sommrey", - "name" : "Jorg Sommrey" - }, - { - "name" : "Julien Fiegehenn", - "drilldown" : "Julien Fiegehenn", - "y" : 2 - }, - { - "y" : 8, - "drilldown" : "Luca Ferrari", - "name" : "Luca Ferrari" - }, - { - "name" : "Mark Anderson", - "drilldown" : "Mark Anderson", - "y" : 2 - }, - { - "y" : 3, - "drilldown" : "Peter Campbell Smith", - "name" : "Peter Campbell Smith" - }, - { - "name" : "Robert Ransbottom", - "y" : 2, - "drilldown" : "Robert Ransbottom" - }, - { - "name" : "Roger Bell_West", - "drilldown" : "Roger Bell_West", - "y" : 5 - }, - { - "drilldown" : "Ryan Thompson", - "y" : 3, - "name" : "Ryan Thompson" - }, - { - "y" : 2, - "drilldown" : "Ulrich Rieke", - "name" : "Ulrich Rieke" - } - ], - "colorByPoint" : 1, - "name" : "The Weekly Challenge - 165" + "yAxis" : { + "title" : { + "text" : "Total Solutions" } - ], - "xAxis" : { - "type" : "category" - }, - "subtitle" : { - "text" : "[Champions: 12] Last updated at 2022-05-20 18:05:10 GMT" } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index c799b06ea7..4fdc7c9a64 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,63 +1,63 @@ { - "yAxis" : { - "title" : { - "text" : null - }, - "min" : 0 - }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - }, "title" : { "text" : "The Weekly Challenge Contributions [2019 - 2022]" }, - "legend" : { - "enabled" : "false" - }, "chart" : { "type" : "column" }, - "subtitle" : { - "text" : "Last updated at 2022-05-20 18:05:10 GMT" + "xAxis" : { + "type" : "category", + "labels" : { + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + } + } }, "series" : [ { "name" : "Contributions", - "dataLabels" : { - "color" : "#FFFFFF", - "align" : "right", - "enabled" : "true", - "y" : 10, - "rotation" : -90, - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - }, - "format" : "{point.y:.0f}" - }, "data" : [ [ "Blog", - 2547 + 2548 ], [ "Perl", - 8060 + 8061 ], [ "Raku", - 4777 + 4778 ] - ] + ], + "dataLabels" : { + "format" : "{point.y:.0f}", + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + }, + "y" : 10, + "color" : "#FFFFFF", + "enabled" : "true", + "align" : "right", + "rotation" : -90 + } } ], - "xAxis" : { - "labels" : { - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - } + "legend" : { + "enabled" : "false" + }, + "yAxis" : { + "title" : { + "text" : null }, - "type" : "category" + "min" : 0 + }, + "subtitle" : { + "text" : "Last updated at 2022-05-20 18:29:55 GMT" + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 9161862585..fd26d40b9d 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,17 +1,11 @@ { - "chart" : { - "type" : "column" - }, - "title" : { - "text" : "The Weekly Challenge Language" - }, - "legend" : { - "enabled" : "false" + "tooltip" : { + "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>", + "headerFormat" : "<span style=\"font-size:11px\"></span>", + "followPointer" : "true" }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } + "subtitle" : { + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2022-05-20 18:29:55 GMT" }, "drilldown" : { "series" : [ @@ -34,8 +28,8 @@ ] }, { - "name" : "002", "id" : "002", + "name" : "002", "data" : [ [ "Perl", @@ -53,7 +47,6 @@ }, { "name" : "003", - "id" : "003", "data" : [ [ "Perl", @@ -67,7 +60,8 @@ "Blog", 9 ] - ] + ], + "id" : "003" }, { "data" : [ @@ -88,6 +82,7 @@ "id" : "004" }, { + "id" : "005", "data" : [ [ "Perl", @@ -102,8 +97,7 @@ 12 ] ], - "name" : "005", - "id" : "005" + "name" : "005" }, { "id" : "006", @@ -124,7 +118,6 @@ ] }, { - "name" : "007", "id" : "007", "data" : [ [ @@ -139,7 +132,8 @@ "Blog", 10 ] - ] + ], + "name" : "007" }, { "data" : [ @@ -156,10 +150,11 @@ 12 ] ], - "id" : "008", - "name" : "008" + "name" : "008", + "id" : "008" }, { + "id" : "009", "data" : [ [ "Perl", @@ -174,12 +169,10 @@ 13 ] ], - "name" : "009", - "id" : "009" + "name" : "009" }, { "name" : "010", - "id" : "010", "data" : [ [ "Perl", @@ -193,10 +186,10 @@ "Blog", 11 ] - ] + ], + "id" : "010" }, { - "id" : "011", "name" : "011", "data" : [ [ @@ -211,11 +204,11 @@ "Blog", 10 ] - ] + ], + "id" : "011" }, { "name" : "012", - "id" : "012", "data" : [ [ "Perl", @@ -229,9 +222,11 @@ "Blog", 11 ] - ] + ], + "id" : "012" }, { + "id" : "013", "data" : [ [ "Perl", @@ -246,12 +241,10 @@ 13 ] ], - "name" : "013", - "id" : "013" + "name" : "013" }, { "name" : "014", - "id" : "014", "data" : [ [ "Perl", @@ -265,11 +258,11 @@ "Blog", 15 ] - ] + ], + "id" : "014" }, { "id" : "015", - "name" : "015", "data" : [ [ "Perl", @@ -283,7 +276,8 @@ "Blog", 15 ] - ] + ], + "name" : "015" }, { "id" : "016", @@ -304,6 +298,7 @@ ] }, { + "id" : "017", "data" : [ [ "Perl", @@ -318,10 +313,11 @@ 12 ] ], - "name" : "017", - "id" : "017" + "name" : "017" }, { + "id" : "018", + "name" : "018", "data" : [ [ "Perl", @@ -335,11 +331,10 @@ "Blog", 14 ] - ], - "id" : "018", - "name" : "018" + ] }, { + "name" : "019", "data" : [ [ "Perl", @@ -354,12 +349,9 @@ 13 ] ], - "name" : "019", "id" : "019" }, { - "id" : "020", - "name" : "020", "data" : [ [ "Perl", @@ -373,7 +365,9 @@ "Blog", 13 ] - ] + ], + "name" : "020", + "id" : "020" }, { "data" : [ @@ -394,6 +388,7 @@ "id" : "021" }, { + "name" : "022", "data" : [ [ "Perl", @@ -408,10 +403,10 @@ 10 ] ], - "name" : "022", "id" : "022" }, { + "id" : "023", "data" : [ [ "Perl", @@ -426,7 +421,6 @@ 12 ] ], - "id" : "023", "name" : "023" }, { @@ -448,6 +442,7 @@ "id" : "024" }, { + "name" : "025", "data" : [ [ "Perl", @@ -462,10 +457,10 @@ 12 ] ], - "name" : "025", "id" : "025" }, { + "name" : "026", "data" : [ [ "Perl", @@ -480,12 +475,11 @@ 10 ] ], - "id" : "026", - "name" : "026" + "id" : "026" }, { - "name" : "027", "id" : "027", + "name" : "027", "data" : [ [ "Perl", @@ -503,7 +497,6 @@ }, { "name" : "028", - "id" : "028", "data" : [ [ "Perl", @@ -517,7 +510,8 @@ "Blog", 9 ] - ] + ], + "id" : "028" }, { "id" : "029", @@ -538,7 +532,6 @@ ] }, { - "name" : "030", "id" : "030", "data" : [ [ @@ -553,10 +546,10 @@ "Blog", 10 ] - ] + ], + "name" : "030" }, { - "id" : "031", "name" : "031", "data" : [ [ @@ -571,7 +564,8 @@ "Blog", 9 ] - ] + ], + "id" : "031" }, { "data" : [ @@ -588,10 +582,11 @@ 10 ] ], - "id" : "032", - "name" : "032" + "name" : "032", + "id" : "032" }, { + "name" : "033", "data" : [ [ "Perl", @@ -606,12 +601,10 @@ 10 ] ], - "id" : "033", - "name" : "033" + "id" : "033" }, { "id" : "034", - "name" : "034", "data" : [ [ "Perl", @@ -625,7 +618,8 @@ "Blog", 11 ] - ] + ], + "name" : "034" }, { "data" : [ @@ -642,12 +636,12 @@ 9 ] ], - "id" : "035", - "name" : "035" + "name" : "035", + "id" : "035" }, { - "name" : "036", "id" : "036", + "name" : "036", "data" : [ [ "Perl", @@ -678,8 +672,8 @@ 9 ] ], - "id" : "037", - "name" : "037" + "name" : "037", + "id" : "037" }, { "id" : "038", @@ -700,7 +694,6 @@ ] }, { - "id" : "039", "name" : "039", "data" : [ [ @@ -715,7 +708,8 @@ "Blog", 12 ] - ] + ], + "id" : "039" }, { "data" : [ @@ -755,7 +749,6 @@ }, { "name" : "042", - "id" : "042", "data" : [ [ "Perl", @@ -769,11 +762,11 @@ "Blog", 11 ] - ] + ], + "id" : "042" }, { "id" : "043", - "name" : "043", "data" : [ [ "Perl", @@ -787,9 +780,11 @@ "Blog", 11 ] - ] + ], + "name" : "043" }, { + "name" : "044", "data" : [ [ "Perl", @@ -804,12 +799,11 @@ 11 ] ], - "id" : "044", - "name" : "044" + "id" : "044" }, { - "name" : "045", "id" : "045", + "name" : "045", "data" : [ [ "Perl", @@ -827,7 +821,6 @@ }, { "id" : "046", - "name" : "046", "data" : [ [ "Perl", @@ -841,7 +834,8 @@ "Blog", 10 ] - ] + ], + "name" : "046" }, { "id" : "047", @@ -862,8 +856,6 @@ ] }, { - "name" : "048", - "id" : "048", |
