diff options
| -rw-r--r-- | challenge-044/luca-ferrari/README | 1 | ||||
| -rw-r--r-- | challenge-044/luca-ferrari/raku/ch-1.p6 | 42 | ||||
| -rw-r--r-- | challenge-044/luca-ferrari/raku/ch-2.p6 | 55 | ||||
| -rw-r--r-- | stats/pwc-challenge-043.json | 423 | ||||
| -rw-r--r-- | stats/pwc-current.json | 418 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 66 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 371 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 392 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 100 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 56 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 48 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 42 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 36 |
14 files changed, 1137 insertions, 953 deletions
diff --git a/challenge-044/luca-ferrari/README b/challenge-044/luca-ferrari/README new file mode 100644 index 0000000000..36518848d1 --- /dev/null +++ b/challenge-044/luca-ferrari/README @@ -0,0 +1 @@ +Solutions by Luca Ferrari. diff --git a/challenge-044/luca-ferrari/raku/ch-1.p6 b/challenge-044/luca-ferrari/raku/ch-1.p6 new file mode 100644 index 0000000000..54defcef42 --- /dev/null +++ b/challenge-044/luca-ferrari/raku/ch-1.p6 @@ -0,0 +1,42 @@ +#!env perl6 + +# Perl Weekly Challenge 44 +# Task 1 +# You are given a string “123456789”. +# Write a script that would insert ”+” or ”-” in between +# digits so that when you evaluate, the result should be 100. +# +# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-044/> + +my $string = '123456789'; +my @digits = $string.comb; +my @operators = [ ' + ', ' - ', '' ] xx @digits.elems; + + + +# produce a set of strings by combining all possible operators +# into all possible digits. +# Explaination: +# @digits Z @operators creates a list of elements +# with all the digits and applicable signs, something like (1 [+ - ]) (2 [+ - ]) +# +# then the slip flattens the list and remap it to another list +# +# then the hyperoperator concatenates everything as a single string +# +# In the loop the spaces are removed, then the string is split by the sign +# and the .Int method computes the value of every part. +for [X~] map { .Slip }, (@digits Z @operators) { + + # remove extra spaces + my $expression = .Str.subst( ' ', '', :g ); + + my $sum = 0; + for $expression ~~ m:g/ (<[- + ]>\d+)/ { + $sum += .Int; + } + + + say "Expression [$expression] = $sum" if $sum == 100; + +} diff --git a/challenge-044/luca-ferrari/raku/ch-2.p6 b/challenge-044/luca-ferrari/raku/ch-2.p6 new file mode 100644 index 0000000000..fb597b6cbb --- /dev/null +++ b/challenge-044/luca-ferrari/raku/ch-2.p6 @@ -0,0 +1,55 @@ +#!env perl6 + +# Perl Weekly Challenge 44 +# Task 2 +# You have only $1 left at the start of the week. +# You have been given an opportunity to make it $200. The rule is simple with every move you can either double what +# you have or add another $1. Write a script to help you get $200 with the smallest number of moves. +# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-044/> +# +# Start with one buck, +# then double to get 2 $, +# then add one buck to get 3 $, +# then double to get 6 $, +# then double to get 12 $, +# then double to get 24 $, +# then add one buck to get 25 $, +# then double to get 50 $, +# then double to get 100 $, +# then double to get 200 $ +# You need 9 operations to get from 1 $ to 200 $! + + +my $initial-value = 1; +my $final-value = 200; + + +sub MAIN( Int :$final-value = 200, + Int :$initial-value = 1 ){ + my $current-val = $final-value; + my @moves; + + while ( $current-val > $initial-value ) { + + @moves.unshift: '%s to get %d $' + .sprintf( $current-val %% 2 ?? 'double' !! 'add one buck', $current-val ); + $current-val = $current-val %% 2 ?? $current-val / 2 !! $current-val - 1; + + # given $current-val %% 2 { + # when .so { + # @moves.unshift: 'double to get %d $'.sprintf( $current-val ); + # $current-val /= 2; + # } + # when ! .so { + # @moves.unshift: 'add one buck to get %d $'.sprintf( $current-val ); + # $current-val -= 1; + # } + # }; + } + + @moves.unshift: 'Start with one buck'; + @moves.join( ",\n then ").say; + 'You need %d operations to get from %d $ to %d $!'.sprintf( @moves.elems - 1, $initial-value, $final-value ).say; + +} + diff --git a/stats/pwc-challenge-043.json b/stats/pwc-challenge-043.json new file mode 100644 index 0000000000..e26bbb7183 --- /dev/null +++ b/stats/pwc-challenge-043.json @@ -0,0 +1,423 @@ +{ + "plotOptions" : { + "series" : { + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + }, + "borderWidth" : 0 + } + }, + "title" : { + "text" : "Perl Weekly Challenge - 043" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "chart" : { + "type" : "column" + }, + "xAxis" : { + "type" : "category" + }, + "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/>" + }, + "series" : [ + { + "data" : [ + { + "drilldown" : "Adam Russell", + "y" : 3, + "name" : "Adam Russell" + }, + { + "name" : "Alicia Bielsa", + "drilldown" : "Alicia Bielsa", + "y" : 1 + }, + { + "drilldown" : "Andrezgz", + "y" : 2, + "name" : "Andrezgz" + }, + { + "name" : "Arne Sommer", + "y" : 3, + "drilldown" : "Arne Sommer" + }, + { + "name" : "Burkhard Nickels", + "drilldown" : "Burkhard Nickels", + "y" : 4 + }, + { + "name" : "Colin Crain", + "drilldown" : "Colin Crain", + "y" : 2 + }, + { + "name" : "Cristina Heredia", + "drilldown" : "Cristina Heredia", + "y" : 2 + }, + { + "name" : "Dave Jacoby", + "drilldown" : "Dave Jacoby", + "y" : 3 + }, + { + "name" : "Duane Powell", + "y" : 2, + "drilldown" : "Duane Powell" + }, + { + "name" : "E. Choroba", + "y" : 3, + "drilldown" : "E. Choroba" + }, + { + "y" : 5, + "drilldown" : "Jaldhar H. Vyas", + "name" : "Jaldhar H. Vyas" + }, + { + "name" : "Javier Luque", + "y" : 5, + "drilldown" : "Javier Luque" + }, + { + "y" : 5, + "drilldown" : "Laurent Rosenfeld", + "name" : "Laurent Rosenfeld" + }, + { + "y" : 2, + "drilldown" : "Luca Ferrari", + "name" : "Luca Ferrari" + }, + { + "name" : "Markus Holzer", + "y" : 2, + "drilldown" : "Markus Holzer" + }, + { + "drilldown" : "Roger Bell West", + "y" : 4, + "name" : "Roger Bell West" + }, + { + "name" : "Ruben Westerberg", + "y" : 4, + "drilldown" : "Ruben Westerberg" + }, + { + "drilldown" : "Ryan Thompson", + "y" : 6, + "name" : "Ryan Thompson" + }, + { + "name" : "Saif Ahmed", + "y" : 2, + "drilldown" : "Saif Ahmed" + }, + { + "y" : 2, + "drilldown" : "Simon Proctor", + "name" : "Simon Proctor" + }, + { + "name" : "Wanderdoc", + "y" : 2, + "drilldown" : "Wanderdoc" + } + ], + "colorByPoint" : 1, + "name" : "Perl Weekly Challenge - 043" + } + ], + "subtitle" : { + "text" : "[Champions: 21] Last updated at 2020-01-20 17:11:23 GMT" + }, + "legend" : { + "enabled" : 0 + }, + "drilldown" : { + "series" : [ + { + "id" : "Adam Russell", + "name" : "Adam Russell", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 1 + ] + ], + "name" : "Alicia Bielsa", + "id" : "Alicia Bielsa" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Andrezgz", + "id" : "Andrezgz" + }, + { + "name" : "Arne Sommer", + "id" : "Arne Sommer", + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "name" : "Burkhard Nickels", + "id" : "Burkhard Nickels", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ] + }, + { + "id" : "Colin Crain", + "name" : "Colin Crain", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "id" : "Cristina Heredia", + "name" : "Cristina Heredia", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Dave Jacoby", + "name" : "Dave Jacoby" + }, + { + "name" : "Duane Powell", + "id" : "Duane Powell", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "id" : "E. Choroba", + "name" : "E. Choroba", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Jaldhar H. Vyas", + "id" : "Jaldhar H. Vyas" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Javier Luque", + "name" : "Javier Luque" + }, + { + "name" : "Laurent Rosenfeld", + "id" : "Laurent Rosenfeld", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "name" : "Luca Ferrari", + "id" : "Luca Ferrari", + "data" : [ + [ + "Raku", + 2 + ] + ] + }, + { + "data" : [ + [ + "Raku", + 2 + ] + ], + "name" : "Markus Holzer", + "id" : "Markus Holzer" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ], + "id" : "Roger Bell West", + "name" : "Roger Bell West" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ], + "id" : "Ruben Westerberg", + "name" : "Ruben Westerberg" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 2 + ] + ], + "name" : "Ryan Thompson", + "id" : "Ryan Thompson" + }, + { + "id" : "Saif Ahmed", + "name" : "Saif Ahmed", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "id" : "Simon Proctor", + "name" : "Simon Proctor", + "data" : [ + [ + "Raku", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Wanderdoc", + "name" : "Wanderdoc" + } + ] + } +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index e8ce10c980..17500ee0d1 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,423 +1,63 @@ { + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + } + } + }, + "title" : { + "text" : "Perl Weekly Challenge - 044" + }, "yAxis" : { "title" : { "text" : "Total Solutions" } }, - "tooltip" : { - "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/>", - "followPointer" : 1 - }, - "subtitle" : { - "text" : "[Champions: 21] Last updated at 2020-01-20 16:52:39 GMT" - }, - "legend" : { - "enabled" : 0 - }, "xAxis" : { "type" : "category" }, + "chart" : { + "type" : "column" + }, + "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/>" + }, "series" : [ { - "name" : "Perl Weekly Challenge - 043", - "colorByPoint" : 1, + "name" : "Perl Weekly Challenge - 044", "data" : [ { - "name" : "Adam Russell", - "y" : 3, - "drilldown" : "Adam Russell" - }, - { - "drilldown" : "Alicia Bielsa", - "y" : 1, - "name" : "Alicia Bielsa" - }, - { - "drilldown" : "Andrezgz", - "y" : 2, - "name" : "Andrezgz" - }, - { - "y" : 3, - "name" : "Arne Sommer", - "drilldown" : "Arne Sommer" - }, - { - "drilldown" : "Burkhard Nickels", - "y" : 4, - "name" : "Burkhard Nickels" - }, - { - "y" : 2, - "name" : "Colin Crain", - "drilldown" : "Colin Crain" - }, - { - "drilldown" : "Cristina Heredia", - "y" : 2, - "name" : "Cristina Heredia" - }, - { - "drilldown" : "Dave Jacoby", - "y" : 3, - "name" : "Dave Jacoby" - }, - { - "drilldown" : "Duane Powell", - "y" : 2, - "name" : "Duane Powell" - }, - { - "drilldown" : "E. Choroba", - "name" : "E. Choroba", - "y" : 3 - }, - { - "drilldown" : "Jaldhar H. Vyas", - "name" : "Jaldhar H. Vyas", - "y" : 5 - }, - { - "y" : 5, - "name" : "Javier Luque", - "drilldown" : "Javier Luque" - }, - { - "drilldown" : "Laurent Rosenfeld", - "y" : 5, - "name" : "Laurent Rosenfeld" - }, - { - "name" : "Luca Ferrari", - "y" : 2, - "drilldown" : "Luca Ferrari" - }, - { - "drilldown" : "Markus Holzer", - "y" : 2, - "name" : "Markus Holzer" - }, - { - "drilldown" : "Roger Bell West", - "y" : 4, - "name" : "Roger Bell West" - }, - { - "name" : "Ruben Westerberg", - "y" : 4, - "drilldown" : "Ruben Westerberg" - }, - { - "name" : "Ryan Thompson", - "y" : 6, - "drilldown" : "Ryan Thompson" - }, - { - "name" : "Saif Ahmed", - "y" : 2, - "drilldown" : "Saif Ahmed" - }, - { - "drilldown" : "Simon Proctor", - "y" : 2, - "name" : "Simon Proctor" - }, - { "y" : 2, - "name" : "Wanderdoc", - "drilldown" : "Wanderdoc" + "drilldown" : "Luca Ferrari", + "name" : "Luca Ferrari" } - ] + ], + "colorByPoint" : 1 } ], - "title" : { - "text" : "Perl Weekly Challenge - 043" - }, - "chart" : { - "type" : "column" + "subtitle" : { + "text" : "[Champions: 1] Last updated at 2020-01-20 17:11:23 GMT" }, "drilldown" : { "series" : [ { "data" : [ [ - "Perl", - 2 - ], - [ - "Blog", - 1 - ] - ], - "id" : "Adam Russell", - "name" : "Adam Russell" - }, - { - "data" : [ - [ - "Perl", - 1 - ] - ], - "name" : "Alicia Bielsa", - "id" : "Alicia Bielsa" - }, - { - "data" : [ - [ - "Perl", - 2 - ] - ], - "id" : "Andrezgz", - "name" : "Andrezgz" - }, - { - "data" : [ - [ - "Raku", - 2 - ], - [ - "Blog", - 1 - ] - ], - "name" : "Arne Sommer", - "id" : "Arne Sommer" - }, - { - "name" : "Burkhard Nickels", - "id" : "Burkhard Nickels", - "data" : [ - [ - "Perl", - 2 - ], - [ - "Raku", - 2 - ] - ] - }, - { - "id" : "Colin Crain", - "name" : "Colin Crain", - "data" : [ - [ - "Perl", - 2 - ] - ] - }, - { - "id" : "Cristina Heredia", - "name" : "Cristina Heredia", - "data" : [ - [ - "Perl", - 2 - ] - ] - }, - { - "data" : [ - [ - "Perl", - 2 - ], - [ - "Blog", - 1 - ] - ], - "name" : "Dave Jacoby", - "id" : "Dave Jacoby" - }, - { - "data" : [ - [ - "Perl", - 2 - ] - ], - "id" : "Duane Powell", - "name" : "Duane Powell" - }, - { - "id" : "E. Choroba", - "name" : "E. Choroba", - "data" : [ - [ - "Perl", - 2 - ], - [ - "Blog", - 1 - ] - ] - }, - { - "data" : [ - [ - "Perl", - 2 - ], - [ - "Raku", - 2 - ], - [ - "Blog", - 1 - ] - ], - "name" : "Jaldhar H. Vyas", - "id" : "Jaldhar H. Vyas" - }, - { - "id" : "Javier Luque", - "name" : "Javier Luque", - "data" : [ - [ - "Perl", - 2 - ], - [ - "Raku", - 2 - ], - [ - "Blog", - 1 - ] - ] - }, - { - "name" : "Laurent Rosenfeld", - "id" : "Laurent Rosenfeld", - "data" : [ - [ - "Perl", - 2 - ], - [ - "Raku", - 2 - ], - [ - "Blog", - 1 - ] - ] - }, - { - "data" : [ - [ "Raku", 2 ] ], "id" : "Luca Ferrari", "name" : "Luca Ferrari" - }, - { - "id" : "Markus Holzer", - "name" : "Markus Holzer", - "data" : [ - [ - "Raku", - 2 - ] - ] - }, - { - "data" : [ - [ - "Perl", - 2 - ], - [ - "Raku", - 2 - ] - ], - "name" : "Roger Bell West", - "id" : "Roger Bell West" - }, - { - "name" : "Ruben Westerberg", - "id" : "Ruben Westerberg", - "data" : [ - [ - "Perl", - 2 - ], - [ - "Raku", - 2 - ] - ] - }, - { - "data" : [ - [ - "Perl", - 2 - ], - [ - "Raku", - 2 - ], - [ - "Blog", - 2 - ] - ], - "name" : "Ryan Thompson", - "id" : "Ryan Thompson" - }, - { - "name" : "Saif Ahmed", - "id" : "Saif Ahmed", - "data" : [ - [ - "Perl", - 2 - ] - ] - }, - { - "data" : [ - [ - "Raku", - 2 - ] - ], - "name" : "Simon Proctor", - "id" : "Simon Proctor" - }, - { - "name" : "Wanderdoc", - "id" : "Wanderdoc", - "data" : [ - [ - "Perl", - 2 - ] - ] } ] }, - "plotOptions" : { - "series" : { - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 - } + "legend" : { + "enabled" : 0 } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index ef615c9bf4..fbfd39a646 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,12 +1,39 @@ { + "title" : { + "text" : "Perl Weekly Challenge Contributions [2019 - 2020]" + }, + "xAxis" : { + "labels" : { + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + } + }, + "type" : "category" + }, "chart" : { "type" : "column" }, - "title" : { - "text" : "Perl Weekly Challenge Contributions [2019 - 2020]" + "yAxis" : { + "title" : { + "text" : null + }, + "min" : 0 }, "series" : [ { + "dataLabels" : { + "rotation" : -90, + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + }, + "color" : "#FFFFFF", + "align" : "right", + "enabled" : "true", + "format" : "{point.y:.0f}", + "y" : 10 + }, "data" : [ [ "Blog", @@ -18,46 +45,19 @@ ], [ "Raku", - 1070 + 1072 ] ], - "dataLabels" : { - "color" : "#FFFFFF", - "enabled" : "true", - "rotation" : -90, - "y" : 10, - "format" : "{point.y:.0f}", - "align" : "right", - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - } - }, "name" : "Contributions" } ], - "xAxis" : { - "labels" : { - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - } - }, - "type" : "category" - }, "subtitle" : { - "text" : "Last updated at 2020-01-20 16:52:39 GMT" - }, - "legend" : { - "enabled" : "false" + "text" : "Last updated at 2020-01-20 17:11:23 GMT" }, "tooltip" : { "pointFormat" : "<b>{point.y:.0f}</b>" }, - "yAxis" : { - "title" : { - "text" : null - }, - "min" : 0 + "legend" : { + "enabled" : "false" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index cfe6a009c6..4ea80de3f7 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,4 +1,7 @@ { + "subtitle" : { + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2020-01-20 17:11:23 GMT" + }, "series" : [ { "data" : [ @@ -8,34 +11,34 @@ "drilldown" : "001" }, { - "drilldown" : "002", + "name" : "#002", "y" : 109, - "name" : "#002" + "drilldown" : "002" }, { - "drilldown" : "003", "name" : "#003", - "y" : 71 + "y" : 71, + "drilldown" : "003" }, { - "drilldown" : "004", "y" : 91, + "drilldown" : "004", "name" : "#004" }, { "y" : 71, - "name" : "#005", - "drilldown" : "005" + "drilldown" : "005", + "name" : "#005" }, { "drilldown" : "006", - "name" : "#006",< |
