diff options
| -rw-r--r-- | challenge-267/laurent-rosenfeld/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-267/laurent-rosenfeld/perl/ch-1.pl | 18 | ||||
| -rw-r--r-- | challenge-267/laurent-rosenfeld/raku/ch-1.raku | 12 | ||||
| -rwxr-xr-x | challenge-267/wanderdoc/perl/ch-1.pl | 55 | ||||
| -rwxr-xr-x | challenge-267/wanderdoc/perl/ch-2.pl | 80 | ||||
| -rw-r--r-- | stats/pwc-current.json | 253 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 54 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 3700 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 400 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 46 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 90 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 54 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 106 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 58 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary-271-300.json | 112 | ||||
| -rw-r--r-- | stats/pwc-summary-301-330.json | 44 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 42 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 32 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 52 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 58 |
21 files changed, 2786 insertions, 2521 deletions
diff --git a/challenge-267/laurent-rosenfeld/blog.txt b/challenge-267/laurent-rosenfeld/blog.txt new file mode 100644 index 0000000000..bcb0bd2add --- /dev/null +++ b/challenge-267/laurent-rosenfeld/blog.txt @@ -0,0 +1 @@ +https://blogs.perl.org/users/laurent_r/2024/05/perl-weekly-challenge-267-product-sign.html diff --git a/challenge-267/laurent-rosenfeld/perl/ch-1.pl b/challenge-267/laurent-rosenfeld/perl/ch-1.pl new file mode 100644 index 0000000000..48664471e4 --- /dev/null +++ b/challenge-267/laurent-rosenfeld/perl/ch-1.pl @@ -0,0 +1,18 @@ +use strict; +use warnings; +use feature 'say'; + +sub product_sign { + my $result = 1; + for my $i (@_) { + $result *= $i <=> 0; + } + return $result; +} +my @tests = ( [<-1 -2 -3 -4 3 2 1>], + [<1 2 0 -2 -1>], + [<-1 -1 1 -1 2>] ); +for my $test (@tests) { + printf "%-18s => ", "@$test"; + say product_sign @$test; +} diff --git a/challenge-267/laurent-rosenfeld/raku/ch-1.raku b/challenge-267/laurent-rosenfeld/raku/ch-1.raku new file mode 100644 index 0000000000..d662ff5c01 --- /dev/null +++ b/challenge-267/laurent-rosenfeld/raku/ch-1.raku @@ -0,0 +1,12 @@ +sub product-sign (@in) { + my $result = 1; + for @in -> $i { + $result *= $i cmp 0; + } + return $result; +} +my @tests = <-1 -2 -3 -4 3 2 1>, <1 2 0 -2 -1>, <-1 -1 1 -1 2>; +for @tests -> @test { + printf "%-18s => ", "@test[]"; + say product-sign @test; +} diff --git a/challenge-267/wanderdoc/perl/ch-1.pl b/challenge-267/wanderdoc/perl/ch-1.pl new file mode 100755 index 0000000000..0a57b18750 --- /dev/null +++ b/challenge-267/wanderdoc/perl/ch-1.pl @@ -0,0 +1,55 @@ +#!perl
+use strict;
+use warnings FATAL => qw(all);
+
+=prompt
+You are given an array of @ints.
+
+Write a script to find the sign of product of all integers in the given array. The sign is 1 if the product is positive, -1 if the product is negative and 0 if product is zero.
+Example 1
+
+Input: @ints = (-1, -2, -3, -4, 3, 2, 1)
+Output: 1
+
+The product -1 x -2 x -3 x -4 x 3 x 2 x 1 => 144 > 0
+
+Example 2
+
+Input: @ints = (1, 2, 0, -2, -1)
+Output: 0
+
+The product 1 x 2 x 0 x -2 x -1 => 0
+
+Example 3
+
+Input: @ints = (-1, -1, 1, -1, 2)
+Output: -1
+
+The product -1 x -1 x 1 x -1 x 2 => -2 < 0
+=cut
+
+
+use Test2::V0;
+
+is(product_sign(-1, -2, -3, -4, 3, 2, 1), 1, 'Example 1');
+is(product_sign(1, 2, 0, -2, -1), 0, 'Example 2');
+is(product_sign(-1, -1, 1, -1, 2), -1, 'Example 3');
+done_testing();
+
+
+
+sub product_sign
+{
+ my @arr = @_;
+ my $sign = 1;
+ for my $elm ( @arr )
+ {
+ return 0 if 0 == $elm;
+ if ($elm > 0 and $sign > 0) { $sign = 1; }
+ elsif ($elm > 0 and $sign < 0) { $sign = -1; }
+ elsif ($elm < 0 and $sign > 0) { $sign = -1; }
+ elsif ($elm < 0 and $sign < 0) { $sign = 1; }
+ else {print "Debug: \$sign = $sign and \$elm = $elm$/";}
+ }
+ return $sign;
+}
\ No newline at end of file diff --git a/challenge-267/wanderdoc/perl/ch-2.pl b/challenge-267/wanderdoc/perl/ch-2.pl new file mode 100755 index 0000000000..2a96644eec --- /dev/null +++ b/challenge-267/wanderdoc/perl/ch-2.pl @@ -0,0 +1,80 @@ +#!perl
+use strict;
+use warnings FATAL => qw(all);
+
+=prompt
+You are given a string, $str, and a 26-items array @widths containing the width of each character from a to z.
+
+Write a script to find out the number of lines and the width of the last line needed to display the given string, assuming you can only fit 100 width units on a line.
+Example 1
+
+Input: $str = "abcdefghijklmnopqrstuvwxyz"
+ @widths = (10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10)
+Output: (3, 60)
+
+Line 1: abcdefghij (100 pixels)
+Line 2: klmnopqrst (100 pixels)
+Line 3: uvwxyz (60 pixels)
+
+Example 2
+
+Input: $str = "bbbcccdddaaa"
+ @widths = (4,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10)
+Output: (2, 4)
+
+Line 1: bbbcccdddaa (98 pixels)
+Line 2: a (4 pixels)
+
+=cut
+
+use constant LINE_LENGTH => 100;
+use Test2::V0;
+
+is(
+ line_counts("abcdefghijklmnopqrstuvwxyz", [10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]),
+ [3, 60],
+ 'Example 1');
+is(
+ line_counts("bbbcccdddaaa", [4,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]),
+ [2, 4],
+ 'Example 2');
+
+done_testing();
+
+
+
+sub line_counts
+{
+ my ($str, $wds_aref) = @_;
+
+
+ my %width;
+ @width{'a' .. 'z'} = @$wds_aref;
+
+ my @letters = split(//,$str);
+ my @output;
+ my @this_line;
+ my $this_length = 0;
+ for my $idx ( 0 .. $#letters )
+ {
+ if ( $this_length + $width{ $letters[$idx] } <= LINE_LENGTH )
+ {
+ push @this_line, $letters[$idx];
+
+ $this_length += $width{ $letters[$idx] };
+
+ if ( $idx == $#letters )
+ {
+ push @output, [ join('', @this_line), $this_length];
+ }
+ }
+ else
+ {
+ push @output, [ join('', @this_line), $this_length];
+ @this_line = ();
+ $this_length = 0;
+ redo;
+ }
+ }
+ return [scalar @output, $output[-1][1]];
+}
\ No newline at end of file diff --git a/stats/pwc-current.json b/stats/pwc-current.json index ff533451e1..b96486ed0d 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,48 +1,46 @@ { - "subtitle" : { - "text" : "[Champions: 16] Last updated at 2024-05-01 08:51:24 GMT" - }, - "chart" : { - "type" : "column" - }, - "plotOptions" : { - "series" : { - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 - } - }, "series" : [ { - "colorByPoint" : 1, - "name" : "The Weekly Challenge - 267", "data" : [ { - "y" : 3, + "y" : 4, + "name" : "Athanasius", + "drilldown" : "Athanasius" + }, + { + "drilldown" : "Bob Lied", "name" : "Bob Lied", - "drilldown" : "Bob Lied" + "y" : 3 }, { - "drilldown" : "Dave Jacoby", + "name" : "Dave Jacoby", "y" : 2, - "name" : "Dave Jacoby" + "drilldown" : "Dave Jacoby" }, { + "drilldown" : "David Ferrone", "y" : 2, - "name" : "David Ferrone", - "drilldown" : "David Ferrone" + "name" : "David Ferrone" }, { - "y" : 2, + "drilldown" : "E. Choroba", "name" : "E. Choroba", - "drilldown" : "E. Choroba" + "y" : 2 }, { + "drilldown" : "Feng Chang", "name" : "Feng Chang", - "y" : 2, - "drilldown" : "Feng Chang" + "y" : 2 + }, + { + "y" : 5, + "name" : "Jaldhar H. Vyas", + "drilldown" : "Jaldhar H. Vyas" + }, + { + "y" : 3, + "name" : "Laurent Rosenfeld", + "drilldown" : "Laurent Rosenfeld" }, { "drilldown" : "Mark Anderson", @@ -50,39 +48,39 @@ "name" : "Mark Anderson" }, { - "drilldown" : "Matthew Neleigh", + "name" : "Matthew Neleigh", "y" : 2, - "name" : "Matthew Neleigh" + "drilldown" : "Matthew Neleigh" }, { - "name" : "Packy Anderson", + "drilldown" : "Packy Anderson", "y" : 5, - "drilldown" : "Packy Anderson" + "name" : "Packy Anderson" }, { + "drilldown" : "Peter Campbell Smith", "name" : "Peter Campbell Smith", - "y" : 3, - "drilldown" : "Peter Campbell Smith" + "y" : 3 }, { - "drilldown" : "Peter Meszaros", + "name" : "Peter Meszaros", "y" : 2, - "name" : "Peter Meszaros" + "drilldown" : "Peter Meszaros" }, { - "name" : "Princy Mangla", + "drilldown" : "Princy Mangla", "y" : 2, - "drilldown" : "Princy Mangla" + "name" : "Princy Mangla" }, { "drilldown" : "Reinier Maliepaard", - "y" : 3, - "name" : "Reinier Maliepaard" + "name" : "Reinier Maliepaard", + "y" : 3 }, { + "drilldown" : "Robbie Hatley", "y" : 3, - "name" : "Robbie Hatley", - "drilldown" : "Robbie Hatley" + "name" : "Robbie Hatley" }, { "y" : 4, @@ -90,18 +88,38 @@ "drilldown" : "Roger Bell_West" }, { + "name" : "Thomas Kohler", + "y" : 4, + "drilldown" : "Thomas Kohler" + }, + { "drilldown" : "Ulrich Rieke", "y" : 4, "name" : "Ulrich Rieke" }, { - "name" : "W. Luis Mochan", "y" : 3, + "name" : "W. Luis Mochan", "drilldown" : "W. Luis Mochan" + }, + { + "name" : "Wanderdoc", + "y" : 2, + "drilldown" : "Wanderdoc" } - ] + ], + "name" : "The Weekly Challenge - 267", + "colorByPoint" : 1 } ], + "subtitle" : { + "text" : "[Champions: 21] Last updated at 2024-05-02 09:01:10 GMT" + }, + "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/>" + }, "drilldown" : { "series" : [ { @@ -111,75 +129,126 @@ 2 ], [ - "Blog", - 1 + "Raku", + 2 ] ], + "name" : "Athanasius", + "id" : "Athanasius" + }, + { + "id" : "Bob Lied", "name" : "Bob Lied", - "id" : "Bob Lied" + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] }, { "name" : "Dave Jacoby", + "id" : "Dave Jacoby", "data" : [ [ "Perl", 2 ] - ], - "id" : "Dave Jacoby" + ] }, { - "id" : "David Ferrone", "data" : [ [ "Perl", 2 ] ], + "id" : "David Ferrone", "name" : "David Ferrone" }, { "name" : "E. Choroba", + "id" : "E. Choroba", "data" : [ [ "Perl", 2 ] - ], - "id" : "E. Choroba" + ] }, { - "id" : "Feng Chang", "data" : [ [ "Raku", 2 ] ], + "id" : "Feng Chang", "name" : "Feng Chang" }, { - "name" : "Mark Anderson", + "name" : "Jaldhar H. Vyas", + "id" : "Jaldhar H. Vyas", "data" : [ [ + "Perl", + 2 + ], + [ "Raku", 2 + ], + [ + "Blog", + 1 ] - ], - "id" : "Mark Anderson" + ] }, { + "name" : "Laurent Rosenfeld", + "id" : "Laurent Rosenfeld", "data" : [ [ "Perl", + 1 + ], + [ + "Raku", + 1 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "data" : [ + [ + "Raku", 2 ] ], + "id" : "Mark Anderson", + "name" : "Mark Anderson" + }, + { + "id" : "Matthew Neleigh", "name" : "Matthew Neleigh", - "id" : "Matthew Neleigh" + "data" : [ + [ + "Perl", + 2 + ] + ] }, { "id" : "Packy Anderson", + "name" : "Packy Anderson", "data" : [ [ "Perl", @@ -193,8 +262,7 @@ "Blog", 1 ] - ], - "name" : "Packy Anderson" + ] }, { "data" : [ @@ -211,27 +279,26 @@ "id" : "Peter Campbell Smith" }, { + "id" : "Peter Meszaros", "name" : "Peter Meszaros", "data" : [ [ "Perl", 2 ] - ], - "id" : "Peter Meszaros" + ] }, { - "name" : "Princy Mangla", "data" : [ [ "Perl", 2 ] ], - "id" : "Princy Mangla" + "id" : "Princy Mangla", + "name" : "Princy Mangla" }, { - "id" : "Reinier Maliepaard", "data" : [ [ "Perl", @@ -242,9 +309,11 @@ 1 ] ], - "name" : "Reinier Maliepaard" + "name" : "Reinier Maliepaard", + "id" : "Reinier Maliepaard" }, { + "id" : "Robbie Hatley", "name" : "Robbie Hatley", "data" : [ [ @@ -255,11 +324,9 @@ "Blog", 1 ] - ], - "id" : "Robbie Hatley" + ] }, { - "name" : "Roger Bell_West", "data" : [ [ "Perl", @@ -270,10 +337,24 @@ 2 ] ], + "name" : "Roger Bell_West", "id" : "Roger Bell_West" }, { - "id" : "Ulrich Rieke", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 2 + ] + ], + "id" : "Thomas Kohler", + "name" : "Thomas Kohler" + }, + { "data" : [ [ "Perl", @@ -284,6 +365,7 @@ 2 ] ], + "id" : "Ulrich Rieke", "name" : "Ulrich Rieke" }, { @@ -297,17 +379,36 @@ 1 ] ], - "name" : "W. Luis Mochan", - "id" : "W. Luis Mochan" + "id" : "W. Luis Mochan", + "name" : "W. Luis Mochan" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Wanderdoc", + "id" : "Wanderdoc" } ] }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, + "chart" : { + "type" : "column" + }, "xAxis" : { "type" : "category" }, - "legend" : { - "enabled" : 0 - }, "title" : { "text" : "The Weekly Challenge - 267" }, @@ -316,9 +417,7 @@ "text" : "Total Solutions" } }, - "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/>" + "legend" : { + "enabled" : 0 } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index c80ab9b111..96604b8e88 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -2,34 +2,43 @@ "series" : [ { "name" : "Contributions", + "dataLabels" : { + "y" : 10, + "align" : "right", + "rotation" : -90, + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + }, + "enabled" : "true", + "format" : "{point.y:.0f}", + "color" : "#FFFFFF" + }, "data" : [ [ "Blog", - 4798 + 4802 ], [ "Perl", - 13837 + 13846 ], [ "Raku", - 8020 + 8025 ] - ], - "dataLabels" : { - "y" : 10, - "color" : "#FFFFFF", - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - }, - "align" : "right", - "enabled" : "true", - "format" : "{point.y:.0f}", - "rotation" : -90 - } + ] } ], + "subtitle" : { + "text" : "Last updated at 2024-05-02 09:01:09 GMT" + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "chart" : { + "type" : "column" + }, "xAxis" : { "labels" : { "style" : { @@ -39,11 +48,8 @@ }, "type" : "category" }, - "subtitle" : { - "text" : "Last updated at 2024-05-01 08:51:23 GMT" - }, - "chart" : { - "type" : "column" + "title" : { + "text" : "The Weekly Challenge Contributions [2019 - 2024]" }, "yAxis" : { "title" : { @@ -51,13 +57,7 @@ }, "min" : 0 }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - }, "legend" : { "enabled" : "false" - }, - "title" : { - "text" : "The Weekly Challenge Contributions [2019 - 2024]" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 6df7728846..7d7aad083e 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,1365 +1,9 @@ { - "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2024-05-01 08:51:24 GMT" - }, - "chart" : { - "type" : "column" - }, - "plotOptions" : { - "series" : { - "borderWidth" : 0, - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - } - } - }, - "xAxis" : { - "type" : "category" - }, - "series" : [ - { - "data" : [ - { - "drilldown" : "001", - "name" : "#001", - "y" : 168 - }, - { - "y" : 133, - "name" : "#002", - "drilldown" : "002" - }, - { - "drilldown" : "003", - "y" : 91, - "name" : "#003" - }, - { - "name" : "#004", - "y" : 106, - "drilldown" : "004" - }, - { - "drilldown" : "005", - "y" : 82, - "name" : "#005" - }, - { - "name" : "#006", - "y" : 63, - "drilldown" : "006" - }, - { - "name" : "#007", - "y" : 71, - "drilldown" : "007" - }, - { - "drilldown" : "008", - "y" : 84, - "name" : "#008" - }, - { - "drilldown" : "009", - "y" : 82, - "name" : "#009" - }, - { - "name" : "#010", - "y" : 71, - "drilldown" : "010" - }, - { - "name" : "#011", - "y" : 91, - "drilldown" : "011" - }, - { - "drilldown" : "012", - "y" : 96, - "name" : "#012" - }, - { - "y" : 88, - "name" : "#013", - "drilldown" : "013" - }, - { - "drilldown" : "014", - "y" : 104, - "name" : "#014" - }, - { - "name" : "#015", - "y" : 103, - "drilldown" : "015" - }, - { - "drilldown" : "016", - "name" : "#016", - "y" : 75 - }, - { - "y" : 87, - "name" : "#017", - "drilldown" : "017" - }, - { - "y" : 84, - "name" : "#018", - "drilldown" : "018" - }, - { - "drilldown" : "019", - "y" : 105, - "name" : "#019" - }, - { - "y" : 103, - "name" : "#020", - "drilldown" : "020" - }, - { - "drilldown" : "021", - "name" : "#021", - "y" : 74 - }, - { - "y" : 72, - "name" : "#022", - "drilldown" : "022" - }, - { - "drilldown" : "023", - "y" : 101, - "name" : "#023" - }, - { - "drilldown" : "024", - "name" : "#024", - "y" : 77 - }, - { - "y" : 62, - "name" : "#025", - "drilldown" : "025" - }, - { - "drilldown" : "026", - "y" : 76, - "name" : "#026" - }, - { - "drilldown" : "027", - "name" : "#027", - "y" : 64 - }, - { - "y" : 82, - "name" : "#028", - "drilldown" : "028" - }, - { - "drilldown" : "029", - "y" : 83, - "name" : "#029" - }, - { - "drilldown" : "030", - "y" : 121, - "name" : "#030" - }, - { - "drilldown" : "031", - "y" : 93, - "name" : "#031" - }, - { - "name" : "#032", - "y" : 98, - "drilldown" : "032" - }, - { - "y" : 114, - "name" : "#033", - "drilldown" : "033" - }, - { - "name" : "#034", - "y" : 70, - "drilldown" : "034" - }, - { - "name" : "#035", - "y" : 68, - "drilldown" : "035" - }, - { - "y" : 70, - "name" : "#036", - "drilldown" : "036" - }, - { - "drilldown" : "037", - "y" : 70, - "name" : "#037" - }, - { - "drilldown" : "038", - "y" : 74, - "name" : "#038" - }, - { - "name" : "#039", - "y" : 68, - "drilldown" : "039" - }, - { - "name" : "#040", - "y" : 77, - "drilldown" : "040" - }, - { - "name" : "#041", - "y" : 80, - "drilldown" : "041" - }, - { - "name" : "#042", - "y" : 98, - "drilldown" : "042" - }, - { - "name" : "#043", - "y" : 72, - "drilldown" : "043" - }, - { - "y" : 90, - "name" : "#044", - "drilldown" : "044" - }, - { - "drilldown" : "045", - "name" : "#045", - "y" : 102 - }, - { - "name" : "#046", - "y" : 93, - "drilldown" : "046" - }, - { - "name" : "#047", - "y" : 88, - "drilldown" : "047" - }, - { - "name" : "#048", - "y" : 112, - "drilldown" : "048" - }, - { - "drilldown" : "049", - "name" : "#049", - "y" : 93 - }, - { - "drilldown" : "050", - "name" : "#050", - "y" : 104 - }, - { - "y" : 95, - "name" : "#051", - "drilldown" : "051" - }, - { - "drilldown" : "052", - "name" : "#052", - "y" : 93 - }, - { - "name" : "#053", - "y" : 105, - "drilldown" : "053" - }, - { - "drilldown" : "054", - "name" : "#054", - "y" : 107 - }, - { |
