diff options
| -rw-r--r-- | challenge-064/javier-luque/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-064/javier-luque/perl/ch-1.pl | 53 | ||||
| -rw-r--r-- | challenge-064/javier-luque/perl/ch-2.pl | 28 | ||||
| -rw-r--r-- | challenge-064/javier-luque/raku/ch-1.p6 | 49 | ||||
| -rw-r--r-- | challenge-064/javier-luque/raku/ch-2.p6 | 21 | ||||
| -rw-r--r-- | stats/pwc-current.json | 95 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 62 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 476 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 706 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 102 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 56 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 48 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 128 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 50 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 382 |
16 files changed, 1236 insertions, 1061 deletions
diff --git a/challenge-064/javier-luque/blog.txt b/challenge-064/javier-luque/blog.txt new file mode 100644 index 0000000000..8b3410c4a1 --- /dev/null +++ b/challenge-064/javier-luque/blog.txt @@ -0,0 +1 @@ +https://perlchallenges.wordpress.com/2020/06/08/perl-weekly-challenge-064/ diff --git a/challenge-064/javier-luque/perl/ch-1.pl b/challenge-064/javier-luque/perl/ch-1.pl new file mode 100644 index 0000000000..f521064b97 --- /dev/null +++ b/challenge-064/javier-luque/perl/ch-1.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl +# Test: ./ch-1.pl +use strict; +use warnings; +use feature qw /say/; + +my @path; +my $matrix = [ + [ 1, 2, 3 ], + [ 4, 5, 6 ], + [ 7, 8, 9 ], +]; + +say min_path($matrix, 0, 0, \@path) + . ": " . (join ' → ', @path); + +# Calculate the max path +sub min_path { + my ($matrix, $m, $n, $path) = @_; + + # Size of matrix + my $max_m = scalar(@{$matrix->[0]}); + my $max_n = scalar(@{$matrix}); + + # Out of bounds + return undef + if ($m >= $max_m || $n >= $max_n); + + # Points in the branch + my $total = $matrix->[$m][$n]; + + # Calculate path + push @$path, $total; + my @path1 = map { $_ } @$path; + my @path2 = map { $_ } @$path; + + # Points produced by each branch + my $score1 = min_path($matrix, $m + 1, $n, \@path1); + my $score2 = min_path($matrix, $m, $n + 1, \@path2); + + # Return the better branch + if ( ($score1 && $score2 && $score1 <= $score2) || + ($score1 && !$score2) ) { + @$path = map { $_ } @path1; + return $total + $score1; + } elsif ( ($score1 && $score2 && $score1 > $score2) || + (!$score1 && $score2) ) { + @$path = map { $_ } @path2; + return $total + $score2; + } else { + return $total; + } +} diff --git a/challenge-064/javier-luque/perl/ch-2.pl b/challenge-064/javier-luque/perl/ch-2.pl new file mode 100644 index 0000000000..8a11885d40 --- /dev/null +++ b/challenge-064/javier-luque/perl/ch-2.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl +# Test: ./ch-2.pl +use strict; +use warnings; +use feature qw /say/; + +my $S = "perlweeklychallenge"; +my @W = ("weekly", "challenge", "perl"); +say $S; +say check_word($S, \@W); + +my $S2 = "perlandraku"; +my @W2 = ("python", "ruby", "haskell"); +say "\n" . $S2; +say check_word($S2, \@W2); + + +sub check_word { + my ($string, $words) = @_; + + my $word_re = join '|', @$words; + my @split_words = + grep { $_ } + split (/($word_re)/, $string); + + return scalar(@split_words) == scalar(@$words) ? + join ' ', @split_words : 0; +} diff --git a/challenge-064/javier-luque/raku/ch-1.p6 b/challenge-064/javier-luque/raku/ch-1.p6 new file mode 100644 index 0000000000..e53d871277 --- /dev/null +++ b/challenge-064/javier-luque/raku/ch-1.p6 @@ -0,0 +1,49 @@ +# Test: perl6 ch-1.p6 +sub MAIN() { + my @path; + my @matrix = [ + [ 1, 2, 3 ], + [ 4, 5, 6 ], + [ 7, 8, 9 ], + ]; + + say min-path(@matrix, 0, 0, @path) + ~ ': ' ~ @path.join(" → "); +} + +# Calculate the max path +sub min-path(@matrix, Int $m, Int $n, @path) { + + # Size of matrix + my $max_m = @matrix[0].elems; + my $max_n = @matrix.elems; + + # Out of bounds + return Nil + if ($m >= $max_m || $n >= $max_n); + + # Points in the branch + my $total = @matrix[$m][$n]; + + # Calculate path + @path.push($total); + my @path1 = @path.map({ $_ }); + my @path2 = @path.map({ $_ }); + + # Points produced by each branch + my $score1 = min-path(@matrix, $m + 1, $n, @path1); + my $score2 = min-path(@matrix, $m, $n + 1, @path2); + + # Return the better branch + if ( ($score1 && $score2 && $score1 <= $score2) || + ($score1 && !$score2) ) { + @path = @path1.map({ $_ }); + return $total + $score1; + } elsif ( ($score1 && $score2 && $score1 > $score2) || + (!$score1 && $score2) ) { + @path = @path2.map({ $_ }); + return $total + $score2; + } else { + return $total; + } +} diff --git a/challenge-064/javier-luque/raku/ch-2.p6 b/challenge-064/javier-luque/raku/ch-2.p6 new file mode 100644 index 0000000000..6f65f428b4 --- /dev/null +++ b/challenge-064/javier-luque/raku/ch-2.p6 @@ -0,0 +1,21 @@ +# Test: perl6 ch-2.p6 + +sub MAIN() { + my $S = "perlweeklychallenge"; + my @W = ("weekly", "challenge", "perl"); + say $S; + say check-word($S, @W); + + my $S2 = "perlandraku"; + my @W2 = ("python", "ruby", "haskell"); + say "\n" ~ $S2; + say check-word($S2, @W2); +} + +sub check-word(Str $string, @words) { + my @split_words = + $string.split(/<@words>/, :v, :skip-empty); + + return (@split_words.elems == @words.elems) ?? + @split_words.join(" ") !! 0; +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index fa7329d640..81d61d5919 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,25 +1,37 @@ { - "chart" : { - "type" : "column" - }, - "title" : { - "text" : "Perl Weekly Challenge - 064" + "subtitle" : { + "text" : "[Champions: 2] Last updated at 2020-06-08 11:53:06 GMT" }, - "legend" : { - "enabled" : 0 + "xAxis" : { + "type" : "category" }, - "plotOptions" : { - "series" : { - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "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/>" }, "drilldown" : { "series" : [ { + "id" : "Javier Luque", + "name" : "Javier Luque", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "id" : "Luca Ferrari", "data" : [ [ "Raku", @@ -30,38 +42,49 @@ 2 ] ], - "name" : "Luca Ferrari", - "id" : "Luca Ferrari" + "name" : "Luca Ferrari" } ] }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, + "title" : { + "text" : "Perl Weekly Challenge - 064" + }, + "chart" : { + "type" : "column" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, "series" : [ { + "colorByPoint" : 1, "data" : [ { - "name" : "Luca Ferrari", + "y" : 5, + "drilldown" : "Javier Luque", + "name" : "Javier Luque" + }, + { + "y" : 4, "drilldown" : "Luca Ferrari", - "y" : 4 + "name" : "Luca Ferrari" } ], - "name" : "Perl Weekly Challenge - 064", - "colorByPoint" : 1 + "name" : "Perl Weekly Challenge - 064" } ], - "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/>" - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "xAxis" : { - "type" : "category" - }, - "subtitle" : { - "text" : "[Champions: 1] Last updated at 2020-06-08 11:33:37 GMT" + "legend" : { + "enabled" : 0 } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index f2045be768..88a5ddfdd8 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,52 +1,36 @@ { - "xAxis" : { - "type" : "category", - "labels" : { - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - } - } - }, - "yAxis" : { - "min" : 0, - "title" : { - "text" : null - } - }, - "subtitle" : { - "text" : "Last updated at 2020-06-08 11:33:37 GMT" - }, - "legend" : { - "enabled" : "false" - }, "title" : { "text" : "Perl Weekly Challenge Contributions [2019 - 2020]" }, "chart" : { "type" : "column" }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" + "yAxis" : { + "min" : 0, + "title" : { + "text" : null + } }, "series" : [ { + "name" : "Contributions", "data" : [ [ "Blog", - 732 + 733 ], [ "Perl", - 2642 + 2644 ], [ "Raku", - 1675 + 1677 ] ], - "name" : "Contributions", "dataLabels" : { + "align" : "right", + "color" : "#FFFFFF", "rotation" : -90, "enabled" : "true", "y" : 10, @@ -54,10 +38,26 @@ "fontSize" : "13px", "fontFamily" : "Verdana, sans-serif" }, - "format" : "{point.y:.0f}", - "align" : "right", - "color" : "#FFFFFF" + "format" : "{point.y:.0f}" } } - ] + ], + "legend" : { + "enabled" : "false" + }, + "xAxis" : { + "type" : "category", + "labels" : { + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + } + } + }, + "subtitle" : { + "text" : "Last updated at 2020-06-08 11:53:05 GMT" + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index b3afc9e042..b19460d0ba 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,69 +1,55 @@ { - "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2020-06-08 11:33:37 GMT" - }, - "xAxis" : { - "type" : "category" - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "tooltip" : { - "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>", - "followPointer" : "true", - "headerFormat" : "<span style=\"font-size:11px\"></span>" + "legend" : { + "enabled" : "false" }, "series" : [ { - "colorByPoint" : "true", "name" : "Perl Weekly Challenge Languages", "data" : [ { - "y" : 142, + "name" : "#001", "drilldown" : "001", - "name" : "#001" + "y" : 142 }, { - "name" : "#002", "drilldown" : "002", - "y" : 109 + "y" : 109, + "name" : "#002" }, { "name" : "#003", - "drilldown" : "003", - "y" : 71 + "y" : 71, + "drilldown" : "003" }, { "drilldown" : "004", - "name" : "#004", - "y" : 91 + "y" : 91, + "name" : "#004" }, { "name" : "#005", - "drilldown" : "005", - "y" : 72 + "y" : 72, + "drilldown" : "005" }, { - "y" : 52, "name" : "#006", + "y" : 52, "drilldown" : "006" }, { - "y" : 59, + "name" : "#007", "drilldown" : "007", - "name" : "#007" + "y" : 59 }, { - "drilldown" : "008", "name" : "#008", + "drilldown" : "008", "y" : 72 }, { "y" : 68, - "name" : "#009", - "drilldown" : "009" + "drilldown" : "009", + "name" : "#009" }, { "y" : 60, @@ -71,99 +57,99 @@ "name" : "#010" }, { + "y" : 79, "drilldown" : "011", - "name" : "#011", - "y" : 79 + "name" : "#011" }, { + "y" : 83, "drilldown" : "012", - "name" : "#012", - "y" : 83 + "name" : "#012" }, { + "name" : "#013", "y" : 76, - "drilldown" : "013", - "name" : "#013" + "drilldown" : "013" }, { "name" : "#014", - "drilldown" : "014", - "y" : 96 + "y" : 96, + "drilldown" : "014" }, { + "name" : "#015", "y" : 93, - "drilldown" : "015", - "name" : "#015" + "drilldown" : "015" }, { - "drilldown" : "016", "name" : "#016", - "y" : 66 + "y" : 66, + "drilldown" : "016" }, { - "drilldown" : "017", "name" : "#017", + "drilldown" : "017", "y" : 79 }, { - "name" : "#018", "drilldown" : "018", - "y" : 76 + "y" : 76, + "name" : "#018" }, { "drilldown" : "019", - "name" : "#019", - "y" : 97 + "y" : 97, + "name" : "#019" }, { - "drilldown" : "020", "name" : "#020", - "y" : 95 + "y" : 95, + "drilldown" : "020" }, { "y" : 67, - "name" : "#021", - "drilldown" : "021" + "drilldown" : "021", + "name" : "#021" }, { - "y" : 63, "name" : "#022", - "drilldown" : "022" + "drilldown" : "022", + "y" : 63 }, { "name" : "#023", - "drilldown" : "023", - "y" : 91 + "y" : 91, + "drilldown" : "023" }, { - "drilldown" : "024", "name" : "#024", - "y" : 70 + "y" : 70, + "drilldown" : "024" }, { - "name" : "#025", "drilldown" : "025", - "y" : 55 + "y" : 55, + "name" : "#025" }, { + "name" : "#026", "y" : 70, - "drilldown" : "026", - "name" : "#026" + "drilldown" : "026" }, { - "drilldown" : "027", "name" : "#027", + "drilldown" : "027", "y" : 58 }, { + "y" : 78, "drilldown" : "028", - "name" : "#028", - "y" : 78 + "name" : "#028" }, { "drilldown" : "029", - "name" : "#029", - "y" : 77 + "y" : 77, + "name" : "#029" }, { "y" : 115, @@ -171,9 +157,9 @@ "name" : "#030" }, { - "name" : "#031", + "y" : 87, "drilldown" : "031", - "y" : 87 + "name" : "#031" }, { "name" : "#032", @@ -181,49 +167,49 @@ "y" : 92 }, { - "y" : 108, "drilldown" : "033", + "y" : 108, "name" : "#033" }, { - "y" : 62, "drilldown" : "034", + "y" : 62, "name" : "#034" }, { + "name" : "#035", "y" : 62, - "drilldown" : "035", - "name" : "#035" + "drilldown" : "035" }, { + "drilldown" : "036", "y" : 66, - "name" : "#036", - "drilldown" : "036" + "name" : "#036" }, { - "name" : "#037", + "y" : 65, "drilldown" : "037", - "y" : 65 + "name" : "#037" }, { - "y" : 65, "name" : "#038", + "y" : 65, "drilldown" : "038" }, { - "y" : 60, "name" : "#039", - "drilldown" : "039" + "drilldown" : "039", + "y" : 60 }, { - "drilldown" : "040", "name" : "#040", + "drilldown" : "040", "y" : 71 }, { + "y" : 74, "drilldown" : "041", - "name" : "#041", - "y" : 74 + "name" : "#041" }, { "y" : 88, @@ -231,28 +217,28 @@ "name" : "#042" }, { + "y" : 66, "drilldown" : "043", - "name" : "#043", - "y" : 66 + "name" : "#043" }, { "name" : "#044", - "drilldown" : "044", - "y" : 82 + "y" : 82, + "drilldown" : "044" }, { + "y" : 94, "drilldown" : "045", - "name" : "#045", - "y" : 94 + "name" : "#045" }, { "name" : "#046", - "drilldown" : "046", - "y" : 85 + "y" : 85, + "drilldown" : "046" }, { - "y" : 82, "name" : "#047", + "y" : 82, "drilldown" : "047" }, { @@ -261,24 +247,24 @@ "name" : "#048" }, { - "drilldown" : "049", "name" : "#049", + "drilldown" : "049", "y" : 85 }, { - "y" : 96, "drilldown" : "050", + "y" : 96, "name" : "#050" }, { - "y" : 87, "drilldown" : "051", + "y" : 87, "name" : "#051" }, { "name" : "#052", - "drilldown" : "052", - "y" : 89 + "y" : 89, + "drilldown" : "052" }, { "y" : 99, @@ -286,14 +272,14 @@ "name" : "#053" }, { - "y" : 99, "drilldown" : "054", + "y" : 99, "name" : "#054" }, { "name" : "#055", - "drilldown" : "055", - "y" : 86 + "y" : 86, + "drilldown" : "055" }, { "y" : 93, @@ -301,48 +287,69 @@ "name" : "#056" }, { - "y" : 78, "name" : "#057", - "drilldown" : "057" + "drilldown" : "057", + "y" : 78 }, { + "y" : 61, "drilldown" : "058", - "name" : "#058", - "y" : 61 + "name" : "#058" }, { "drilldown" : "059", - "name" : "#059", - "y" : 82 + "y" : 82, + "name" : "#059" }, { "name" : "#060", - "drilldown" : "060", - "y" : 78 + "y" : 78, + "drilldown" : "060" }, { "drilldown" : "061", - "name" : "#061", - "y" : 79 + "y" : 79, + "name" : "#061" }, { - "y" : 53, "name" : "#062", + "y" : 53, "drilldown" : "062" }, { + "y" : 85, "drilldown" : "063", - "name" : "#063", - "y" : 85 + "name" : "#063" }, { - "drilldown" : "064", "name" : "#064", - "y" : 4 + "drilldown" : "064", + "y" : 9 } - ] + ], + "colorByPoint" : "true" } ], + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "chart" : { + "type" : "column" + }, + "title" : { + "text" : "Perl Weekly Challenge Language" + }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + } + } + }, "drilldown" : { "series" : [ { @@ -364,6 +371,8 @@ ] }, { + "id" : "002", + "name" : "002", "data" : [ [ "Perl", @@ -377,13 +386,9 @@ "Blog", 10 ] - ], - "name" : "002", - "id" : "002" + ] }, { - "id" : "003", - "name" : "003", "data" : [ [ "Perl", @@ -397,9 +402,12 @@ "Blog", 9 ] - ] + ], + "name" : "003", + "id" : "003" }, { + "name" : "004", "data" : [ [ "Perl", @@ -414,10 +422,10 @@ 10 ] ], - "name" : "004", "id" : "004" }, { + "name" : "005", "data" : [ [ "Perl", @@ -432,11 +440,10 @@ 12 ] ], - "name" : "005", "id" : "005" }, { - "name" : "006", + "id" : "006", "data" : [ [ "Perl", @@ -451,10 +458,9 @@ 7 ] ], - "id" : "006" + "name" : "006" }, { - "id" : "007", "data" : [ [ "Perl", @@ -469,9 +475,12 @@ 10 ] ], - "name" : "007" + "name" : "007", + "id" : "007" }, { + "id" : "008", + "name" : "008", "data" : [ [ "Perl", @@ -485,13 +494,9 @@ "Blog", 12 ] - ], - "name" : "008", - "id" : "008" + ] }, { - "id" : "009", - "name" : "009", "data" : [ [ "Perl", @@ -505,10 +510,11 @@ "Blog", 13 ] - ] + ], + "name" : "009", + "id" : "009" }, { - "name" : "010", "data" : [ [ "Perl", @@ -523,10 +529,10 @@ 11 ] ], + "name" : "010", "id" : "010" }, { - "id" : "011", "data" : [ [ "Perl", @@ -541,9 +547,11 @@ 10 ] ], - "name" : "011" + "name" : "011", + "id" : "011" }, { + "name" : "012", "data" : [ [ "Perl", @@ -558,10 +566,10 @@ 11 ] ], - "name" : "012", "id" : "012" }, { + "id" : "013", "data" : [ [ "Perl", @@ -576,11 +584,9 @@ 13 ] ], - "name" : "013", - "id" : "013" + "name" : "013" }, { - "id" : "014", "name" : "014", "data" : [ [ @@ -595,10 +601,10 @@ "Blog", 15 ] - ] + ], + "id" : "014" }, { - "id" : "015", "name" : "015", "data" : [ [ @@ -613,7 +619,8 @@ "Blog", 15 ] - ] + ], + "id" : "015" }, { "id" : "016", @@ -634,7 +641,6 @@ "name" : "016" }, { - "name" : "017", "data" : [ [ "Perl", @@ -649,6 +655,7 @@ 12 ] ], + "name" : "017", "id" : "017" }, { @@ -671,6 +678,7 @@ }, { "id" : "019", + "name" : "019", "data" : [ [ "Perl", @@ -684,11 +692,10 @@ "Blog", 13 ] - ], - "name" : "019" + ] }, { - "name" : "020", + "id" : "020", "data" : [ [ "Perl", @@ -703,7 +710,7 @@ 13 ] ], - "id" : "020" + "name" : "020" }, { "data" : [ @@ -724,7 +731,6 @@ "id" : "021" }, { - "name" : "022", "data" : [ [ |
