diff options
| author | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2024-07-31 09:22:00 +0100 |
|---|---|---|
| committer | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2024-07-31 09:22:00 +0100 |
| commit | e9916addb3e14008166982fce954d0dc8fd3bafa (patch) | |
| tree | dbbcccfbac44e399265466e8bb74f84c344075b5 | |
| parent | 28a5cbe6dfaad242cc3a5b78730cca636944108e (diff) | |
| download | perlweeklychallenge-club-e9916addb3e14008166982fce954d0dc8fd3bafa.tar.gz perlweeklychallenge-club-e9916addb3e14008166982fce954d0dc8fd3bafa.tar.bz2 perlweeklychallenge-club-e9916addb3e14008166982fce954d0dc8fd3bafa.zip | |
- Added solutions by Kjetil Skotheim.
- Added solutions by Wanderdoc.
24 files changed, 2833 insertions, 2687 deletions
diff --git a/challenge-280/wanderdoc/perl/ch-1.pl b/challenge-280/wanderdoc/perl/ch-1.pl new file mode 100755 index 0000000000..c80fefeb97 --- /dev/null +++ b/challenge-280/wanderdoc/perl/ch-1.pl @@ -0,0 +1,49 @@ +#!perl
+use strict;
+use warnings FATAL => qw(all);
+
+=prompt
+You are given a string, $str, containing lowercase English letters only.
+
+Write a script to print the first letter that appears twice.
+Example 1
+
+Input: $str = "acbddbca"
+Output: "d"
+
+Example 2
+
+Input: $str = "abccd"
+Output: "c"
+
+Example 3
+
+Input: $str = "abcdabbb"
+Output: "a"
+
+=cut
+
+
+use Test2::V0;
+is(first_letter_twice(q[acbddbca]), 'd', 'Example 1');
+is(first_letter_twice(q[abccd]), 'c', 'Example 2');
+is(first_letter_twice(q[abcdabbb]), 'a', 'Example 3');
+done_testing();
+
+sub first_letter_twice
+{
+ my $str = $_[0];
+ my %counter;
+ for my $chr ( split(//, $str) )
+ {
+ if ( exists $counter{$chr} )
+ {
+ return $chr;
+ }
+ else
+ {
+ $counter{$chr} = undef;
+ }
+ }
+ return 0; # if no letter appears twice.
+}
\ No newline at end of file diff --git a/challenge-280/wanderdoc/perl/ch-2.pl b/challenge-280/wanderdoc/perl/ch-2.pl new file mode 100755 index 0000000000..e0340d1341 --- /dev/null +++ b/challenge-280/wanderdoc/perl/ch-2.pl @@ -0,0 +1,67 @@ +#!perl
+use strict;
+use warnings FATAL => qw(all);
+
+=prompt
+You are given a string, $str, where every two consecutive vertical bars are grouped into a pair.
+
+Write a script to return the number of asterisks, *, excluding any between each pair of vertical bars.
+Example 1
+
+Input: $str = "p|*e*rl|w**e|*ekly|"
+Ouput: 2
+
+The characters we are looking here are "p" and "w**e".
+
+Example 2
+
+Input: $str = "perl"
+Ouput: 0
+
+Example 3
+
+Input: $str = "th|ewe|e**|k|l***ych|alleng|e"
+Ouput: 5
+
+The characters we are looking here are "th", "e**", "l***ych" and "e".
+
+=cut
+
+use Test2::V0;
+
+is(count_asterisks(q[p|*e*rl|w**e|*ekly|]), 2, 'Example 1');
+is(count_asterisks(q[perl]), 0, 'Example 2');
+is(count_asterisks(q[th|ewe|e**|k|l***ych|alleng|e]), 5, 'Example 3');
+
+done_testing();
+
+
+
+
+sub count_asterisks
+{
+ my $str = $_[0];
+ my @chars = split(//, $str);;
+ my @filtered;
+ my $flag = 0;
+ for my $chr ( @chars )
+ {
+ if ( $chr eq '|' )
+ {
+ if ( $flag == 0 )
+ {
+ $flag = 1;
+ }
+ else
+ {
+ $flag = 0;
+ }
+ }
+ if ( $flag == 0 )
+ {
+ push @filtered, $chr;
+ }
+ }
+ my $count = join('', @filtered) =~ tr/*/*/;
+ return $count;
+}
\ No newline at end of file diff --git a/stats/pwc-current.json b/stats/pwc-current.json index b5ef0bb7a1..1128943a42 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,17 +1,144 @@ { + "title" : { + "text" : "The Weekly Challenge - 280" + }, + "series" : [ + { + "colorByPoint" : 1, + "name" : "The Weekly Challenge - 280", + "data" : [ + { + "name" : "Alexander Karelas", + "drilldown" : "Alexander Karelas", + "y" : 1 + }, + { + "name" : "Dave Jacoby", + "drilldown" : "Dave Jacoby", + "y" : 3 + }, + { + "drilldown" : "David Ferrone", + "y" : 2, + "name" : "David Ferrone" + }, + { + "drilldown" : "E. Choroba", + "y" : 2, + "name" : "E. Choroba" + }, + { + "name" : "Feng Chang", + "drilldown" : "Feng Chang", + "y" : 2 + }, + { + "name" : "Jan Krnavek", + "y" : 2, + "drilldown" : "Jan Krnavek" + }, + { + "name" : "Kjetil Skotheim", + "y" : 2, + "drilldown" : "Kjetil Skotheim" + }, + { + "name" : "Laurent Rosenfeld", + "drilldown" : "Laurent Rosenfeld", + "y" : 6 + }, + { + "name" : "Luca Ferrari", + "drilldown" : "Luca Ferrari", + "y" : 12 + }, + { + "name" : "Mark Anderson", + "drilldown" : "Mark Anderson", + "y" : 2 + }, + { + "drilldown" : "Matthew Neleigh", + "y" : 2, + "name" : "Matthew Neleigh" + }, + { + "name" : "Peter Campbell Smith", + "y" : 3, + "drilldown" : "Peter Campbell Smith" + }, + { + "drilldown" : "Peter Meszaros", + "y" : 2, + "name" : "Peter Meszaros" + }, + { + "y" : 3, + "drilldown" : "Robbie Hatley", + "name" : "Robbie Hatley" + }, + { + "name" : "Thomas Kohler", + "drilldown" : "Thomas Kohler", + "y" : 4 + }, + { + "drilldown" : "Ulrich Rieke", + "y" : 4, + "name" : "Ulrich Rieke" + }, + { + "name" : "W. Luis Mochan", + "drilldown" : "W. Luis Mochan", + "y" : 3 + }, + { + "y" : 2, + "drilldown" : "Wanderdoc", + "name" : "Wanderdoc" + } + ] + } + ], + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "chart" : { + "type" : "column" + }, + "legend" : { + "enabled" : 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/>" + }, "drilldown" : { "series" : [ { + "id" : "Alexander Karelas", + "name" : "Alexander Karelas", "data" : [ [ "Perl", 1 ] - ], - "name" : "Alexander Karelas", - "id" : "Alexander Karelas" + ] }, { + "name" : "Dave Jacoby", "data" : [ [ "Perl", @@ -22,7 +149,6 @@ 1 ] ], - "name" : "Dave Jacoby", "id" : "Dave Jacoby" }, { @@ -46,28 +172,36 @@ ] }, { - "id" : "Feng Chang", "name" : "Feng Chang", "data" : [ [ "Raku", 2 ] - ] + ], + "id" : "Feng Chang" }, { - "id" : "Jan Krnavek", "data" : [ [ "Raku", 2 ] ], - "name" : "Jan Krnavek" + "name" : "Jan Krnavek", + "id" : "Jan Krnavek" + }, + { + "name" : "Kjetil Skotheim", + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Kjetil Skotheim" }, { - "id" : "Laurent Rosenfeld", - "name" : "Laurent Rosenfeld", "data" : [ [ "Perl", @@ -81,10 +215,12 @@ "Blog", 2 ] - ] + ], + "name" : "Laurent Rosenfeld", + "id" : "Laurent Rosenfeld" }, { - "name" : "Luca Ferrari", + "id" : "Luca Ferrari", "data" : [ [ "Raku", @@ -95,30 +231,30 @@ 10 ] ], - "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", "data" : [ [ "Perl", 2 ] ], - "name" : "Matthew Neleigh" + "id" : "Matthew Neleigh" }, { - "id" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith", "data" : [ [ "Perl", @@ -129,20 +265,19 @@ 1 ] ], - "name" : "Peter Campbell Smith" + "id" : "Peter Campbell Smith" }, { - "name" : "Peter Meszaros", + "id" : "Peter Meszaros", "data" : [ [ "Perl", 2 ] ], - "id" : "Peter Meszaros" + "name" : "Peter Meszaros" }, { - "id" : "Robbie Hatley", "name" : "Robbie Hatley", "data" : [ [ @@ -153,9 +288,11 @@ "Blog", 1 ] - ] + ], + "id" : "Robbie Hatley" }, { + "name" : "Thomas Kohler", "data" : [ [ "Perl", @@ -166,11 +303,11 @@ 2 ] ], - "name" : "Thomas Kohler", "id" : "Thomas Kohler" }, { "id" : "Ulrich Rieke", + "name" : "Ulrich Rieke", "data" : [ [ "Perl", @@ -180,12 +317,10 @@ "Raku", 2 ] - ], - "name" : "Ulrich Rieke" + ] }, { "id" : "W. Luis Mochan", - "name" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -195,130 +330,25 @@ "Blog", 1 ] - ] + ], + "name" : "W. Luis Mochan" + }, + { + "id" : "Wanderdoc", + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Wanderdoc" } ] }, "subtitle" : { - "text" : "[Champions: 16] Last updated at 2024-07-30 21:31:21 GMT" + "text" : "[Champions: 18] Last updated at 2024-07-31 08:21:43 GMT" }, "xAxis" : { "type" : "category" - }, - "title" : { - "text" : "The Weekly Challenge - 280" - }, - "legend" : { - "enabled" : 0 - }, - "series" : [ - { - "colorByPoint" : 1, - "name" : "The Weekly Challenge - 280", - "data" : [ - { - "drilldown" : "Alexander Karelas", - "name" : "Alexander Karelas", - "y" : 1 - }, - { - "y" : 3, - "drilldown" : "Dave Jacoby", - "name" : "Dave Jacoby" - }, - { - "y" : 2, - "drilldown" : "David Ferrone", - "name" : "David Ferrone" - }, - { - "name" : "E. Choroba", - "drilldown" : "E. Choroba", - "y" : 2 - }, - { - "name" : "Feng Chang", - "drilldown" : "Feng Chang", - "y" : 2 - }, - { - "y" : 2, - "name" : "Jan Krnavek", - "drilldown" : "Jan Krnavek" - }, - { - "y" : 6, - "name" : "Laurent Rosenfeld", - "drilldown" : "Laurent Rosenfeld" - }, - { - "drilldown" : "Luca Ferrari", - "name" : "Luca Ferrari", - "y" : 12 - }, - { - "y" : 2, - "drilldown" : "Mark Anderson", - "name" : "Mark Anderson" - }, - { - "y" : 2, - "name" : "Matthew Neleigh", - "drilldown" : "Matthew Neleigh" - }, - { - "y" : 3, - "drilldown" : "Peter Campbell Smith", - "name" : "Peter Campbell Smith" - }, - { - "name" : "Peter Meszaros", - "drilldown" : "Peter Meszaros", - "y" : 2 - }, - { - "drilldown" : "Robbie Hatley", - "name" : "Robbie Hatley", - "y" : 3 - }, - { - "name" : "Thomas Kohler", - "drilldown" : "Thomas Kohler", - "y" : 4 - }, - { - "y" : 4, - "drilldown" : "Ulrich Rieke", - "name" : "Ulrich Rieke" - }, - { - "y" : 3, - "name" : "W. Luis Mochan", - "drilldown" : "W. Luis Mochan" - } - ] - } - ], - "chart" : { - "type" : "column" - }, - "plotOptions" : { - "series" : { - "borderWidth" : 0, - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - } - } - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "tooltip" : { - "followPointer" : 1, - "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", - "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>" } } diff --git a/stats/pwc-language-breakdown-2019.json b/stats/pwc-language-breakdown-2019.json index 9883042470..1c25a3f27d 100644 --- a/stats/pwc-language-breakdown-2019.json +++ b/stats/pwc-language-breakdown-2019.json @@ -2,6 +2,7 @@ "drilldown" : { "series" : [ { + "id" : "001", "name" : "001", "data" : [ [ @@ -16,11 +17,11 @@ "Blog", 12 ] - ], - "id" : "001" + ] }, { "id" : "002", + "name" : "002", "data" : [ [ "Perl", @@ -34,10 +35,10 @@ "Blog", 10 ] - ], - "name" : "002" + ] }, { + "id" : "003", "data" : [ [ "Perl", @@ -52,11 +53,9 @@ 9 ] ], - "name" : "003", - "id" : "003" + "name" : "003" }, { - "id" : "004", "data" : [ [ "Perl", @@ -71,9 +70,11 @@ 10 ] ], - "name" : "004" + "name" : "004", + "id" : "004" }, { + "id" : "005", "data" : [ [ "Perl", @@ -88,11 +89,9 @@ 12 ] ], - "name" : "005", - "id" : "005" + "name" : "005" }, { - "name" : "006", "data" : [ [ "Perl", @@ -107,6 +106,7 @@ 7 ] ], + "name" : "006", "id" : "006" }, { @@ -128,6 +128,8 @@ "id" : "007" }, { + "id" : "008", + "name" : "008", "data" : [ [ "Perl", @@ -141,13 +143,10 @@ "Blog", 12 ] - ], - "name" : "008", - "id" : "008" + ] }, { "id" : "009", - "name" : "009", "data" : [ [ "Perl", @@ -161,10 +160,11 @@ "Blog", 13 ] - ] + ], + "name" : "009" }, { - "name" : "010", + "id" : "010", "data" : [ [ "Perl", @@ -179,7 +179,7 @@ 11 ] ], - "id" : "010" + "name" : "010" }, { "data" : [ @@ -218,7 +218,6 @@ "name" : "012" }, { - "name" : "013", "data" : [ [ "Perl", @@ -233,6 +232,7 @@ 13 ] ], + "name" : "013", "id" : "013" }, { @@ -254,7 +254,7 @@ ] }, { - "id" : "015", + "name" : "015", "data" : [ [ "Perl", @@ -269,7 +269,7 @@ 15 ] ], - "name" : "015" + "id" : "015" }, { "id" : "016", @@ -308,7 +308,6 @@ ] }, { - "id" : "018", "data" : [ [ "Perl", @@ -323,10 +322,11 @@ 14 ] ], - "name" : "018" + "name" : "018", + "id" : "018" }, { - "name" : "019", + "id" : "019", "data" : [ [ "Perl", @@ -341,11 +341,10 @@ 13 ] ], - "id" : "019" + "name" : "019" }, { "id" : "020", - "name" : "020", "data" : [ [ "Perl", @@ -359,10 +358,10 @@ "Blog", 13 ] - ] + ], + "name" : "020" }, { - "name" : "021", "data" : [ [ "Perl", @@ -377,6 +376,7 @@ 10 ] ], + "name" : "021", "id" : "021" }, { @@ -398,7 +398,7 @@ ] }, { - "id" : "023", + "name" : "023", "data" : [ [ "Perl", @@ -413,10 +413,10 @@ 12 ] ], - "name" : "023" + "id" : "023" }, { - "id" : "024", + "name" : "024", "data" : [ [ "Perl", @@ -431,7 +431,7 @@ 11 ] ], - "name" : "024" + "id" : "024" }, { "name" : "025", @@ -452,7 +452,6 @@ "id" : "025" }, { - "id" : "026", "data" : [ [ "Perl", @@ -467,7 +466,8 @@ 10 ] ], - "name" : "026" + "name" : "026", + "id" : "026" }, { "data" : [ @@ -489,6 +489,7 @@ }, { "id" : "028", + "name" : "028", "data" : [ [ "Perl", @@ -502,8 +503,7 @@ "Blog", 9 ] - ], - "name" : "028" + ] }, { "name" : "029", @@ -543,7 +543,6 @@ }, { "id" : "031", - "name" : "031", "data" : [ [ "Perl", @@ -557,7 +556,8 @@ "Blog", 9 ] - ] + ], + "name" : "031" }, { "name" : "032", @@ -578,8 +578,6 @@ "id" : "032" }, { - "id" : "033", - "name" : "033", "data" : [ [ "Perl", @@ -593,11 +591,11 @@ "Blog", 10 ] - ] + ], + "name" : "033", + "id" : "033" }, { - "id" : "034", - "name" : "034", "data" : [ [ "Perl", @@ -611,10 +609,13 @@ "Blog", 11 ] - ] + ], + "name" : "034", + "id" : "034" }, { "id" : "035", + "name" : "035", "data" : [ [ "Perl", @@ -628,10 +629,10 @@ "Blog", 9 ] - ], - "name" : "035" + ] }, { + "name" : "036", "data" : [ [ "Perl", @@ -646,7 +647,6 @@ 11 ] ], - "name" : "036", "id" : "036" }, { @@ -669,6 +669,7 @@ }, { "id" : "038", + "name" : "038", "data" : [ [ "Perl", @@ -682,8 +683,7 @@ "Blog", 12 ] - ], - "name" : "038" + ] }, { "name" : "039", @@ -705,7 +705,6 @@ }, { "id" : "040", - "name" : "040", "data" : [ [ "Perl", @@ -719,10 +718,12 @@ "Blog", 10 ] - ] + ], + "name" : "040" }, { "id" : "041", + "name" : "041", "data" : [ [ "Perl", @@ -736,61 +737,82 @@ "Blog", 9 ] - ], - "name" : "041" + ] } ] }, - "title" : { - "text" : "The Weekly Challenge Language" + "tooltip" : { + "headerFormat" : "<span style=\"font-size:11px\"></span>", + "followPointer" : "true", + "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>" }, "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2024-07-30 21:31:21 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2024-07-31 08:21:43 GMT" }, "xAxis" : { "type" : "category" }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, "chart" : { "type" : "column" }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + } + } + }, |
