diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-01-24 21:12:30 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-01-24 21:12:30 +0000 |
| commit | bac75dac372ec9302702a9afaa6608fc02b35207 (patch) | |
| tree | 17ea890f86e405e5d1839d156b32bf7364cacc16 | |
| parent | 82a0002c9e5239704507a807e947c088a92e87b3 (diff) | |
| download | perlweeklychallenge-club-bac75dac372ec9302702a9afaa6608fc02b35207.tar.gz perlweeklychallenge-club-bac75dac372ec9302702a9afaa6608fc02b35207.tar.bz2 perlweeklychallenge-club-bac75dac372ec9302702a9afaa6608fc02b35207.zip | |
- Added solutions by Ulrich Rieke.
| -rw-r--r-- | challenge-044/ulrich-rieke/raku/ch-1.p6 | 204 | ||||
| -rw-r--r-- | challenge-044/ulrich-rieke/raku/ch-2.p6 | 20 | ||||
| -rw-r--r-- | stats/pwc-current.json | 227 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 60 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 316 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 736 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 44 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 106 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 50 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 96 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 44 |
12 files changed, 1091 insertions, 852 deletions
diff --git a/challenge-044/ulrich-rieke/raku/ch-1.p6 b/challenge-044/ulrich-rieke/raku/ch-1.p6 new file mode 100644 index 0000000000..e80d16b88b --- /dev/null +++ b/challenge-044/ulrich-rieke/raku/ch-1.p6 @@ -0,0 +1,204 @@ +use v6 ; + +#in order to create the analogon of list comprehensions, I had to create +#various functions to take account of differing numbers of digit +#combinations. Unfortunately, this led to code repetition. +#to print out the results of the gather-take loops turned out to be more +#difficult than originally envisaged +#somehow you have to circumvent the fact the immutability of resulting +#strings + +sub testSubSequences_8( @numbers ) { + my @sources ; + for (0..7 ) -> $i { + @sources.push( @numbers[ $i ] , -@numbers[ $i ] ) ; + } + my @fittingnumbers = gather { + for @sources[0,1] -> $n0 { + for @sources[2,3] -> $n1 { + for @sources[4,5] -> $n2 { + for @sources[6,7] -> $n3 { + for @sources[8,9] -> $n4 { + for @sources[10,11] -> $n5 { + for @sources[12,13] -> $n6 { + for @sources[14,15] -> $n7 { + if ( $n0 + $n1 + $n2 + $n3 + $n4 + $n5 + $n6 + $n7 ) == 100 { + take $n0 , $n1 , $n2 , $n3 , $n4 , $n5 , $n6 , $n7 ; + } + } + } + } + } + } + } + } + } + } + if @fittingnumbers { + for @fittingnumbers -> @array { + my $str = join '+' , @array ; + $str ~~ s:g/\+\-/\-/ ; + say $str ; + } + } +} + +sub testSubSequences_7( @numbers ) { + my @sources ; + for (0..6 ) -> $i { + @sources.push( @numbers[ $i ] , -@numbers[ $i ] ) ; + } + my @fittingnumbers = gather { + for @sources[0, 1] -> $n0 { + for @sources[2 , 3] -> $n1 { + for @sources[4 , 5] -> $n2 { + for @sources[6 , 7] -> $n3 { + for @sources[8 , 9] -> $n4 { + for @sources[10 , 11 ] -> $n5 { + for @sources[12 , 13] -> $n6 { + if ( $n0 + $n1 + $n2 + $n3 + $n4 + $n5 + $n6 ) == 100 { + take $n0 , $n1 , $n2 , $n3 , $n4 , $n5 , $n6 ; + } + } + } + } + } + } + } + } + } + if @fittingnumbers { + for @fittingnumbers -> @array { + my $str = join '+', @array ; + $str ~~ s:g/\+\-/\-/ ; + say $str ; + } + } +} + +sub testSubSequences_6( @numbers ) { + my @sources ; + for (0..5 ) -> $i { + @sources.push( @numbers[ $i ] , -@numbers[ $i ] ) ; + } + my @fittingnumbers = gather { + for @sources[0,1] -> $n0 { + for @sources[2 , 3] -> $n1 { + for @sources[4 , 5] -> $n2 { + for @sources[6 , 7] -> $n3 { + for @sources[8 , 9] -> $n4 { + for @sources[10, 11] -> $n5 { + if ( $n0 + $n1 + $n2 + $n3 + $n4 + $n5 ) == 100 { + take $n0 , $n1 , $n2 , $n3 , $n4 , $n5 ; + } + } + } + } + } + } + } + } + if @fittingnumbers { + for @fittingnumbers -> @array { + my $str = join '+' , @array ; + $str ~~ s:g/\+\-/\-/ ; + say $str ; + } + } +} + +sub testSubSequences_5( @numbers ) { + my @sources ; + for (0..4 ) -> $i { + @sources.push( @numbers[ $i ] , -@numbers[ $i ] ) ; + } + my @fittingnumbers = gather { + for @sources[0, 1] -> $n0 { + for @sources[2 , 3] -> $n1 { + for @sources[4 , 5] -> $n2 { + for @sources[6 , 7] -> $n3 { + for @sources[8 , 9] -> $n4 { + if ( $n0 + $n1 + $n2 + $n3 + $n4 ) == 100 { + take $n0 , $n1 , $n2 , $n3 , $n4 ; + } + } + } + } + } + } + } + if @fittingnumbers { + for @fittingnumbers -> @array { + my $str = join '+' , @array ; + $str ~~ s:g/\+\-/\-/ ; + s ay $str ; + } + } +} + +sub testSubSequences_4( @numbers ) { + my @sources ; + for (0..3 ) -> $i { + @sources.push( @numbers[ $i ] , -@numbers[ $i ] ) ; + } + my @fittingnumbers = gather { + for @sources[0, 1] -> $n0 { + for @sources[2 , 3] -> $n1 { + for @sources[4, 5] -> $n2 { + for @sources[6, 7] -> $n3 { + if ( $n0 + $n1 + $n2 + $n3 ) == 100 { + take $n0 , $n1 , $n2 , $n3 ; + } + } + } + } + } + } + if @fittingnumbers { + for @fittingnumbers -> @array { + my $str = join '+' , @array ; + $str ~~ s:g/\+\-/\-/ ; + say $str ; + } + } +} + +#function to find the substrings and numbers according to length sequences +sub findNumbers( Str $digits , $seq ) { + my @numbers ; + my $current = 0 ; + for $seq.Array -> $i { + @numbers.push( $digits.substr( $current , $i ).Int) ; + $current += $i ; + } + return @numbers ; +} + + +my $digits = "123456789" ; +#a combination of 3 three-digit-numbers will not result in 100 as a sum! +#therefore, the likely combinations in length are : ( all summing up to 9) +my @likelyCombos = ( (1 , 2 , 2 , 2 , 2 ) , (1 , 1 , 1 , 1 , 1 , 2 , 2 ), + (3 , 2 , 2 , 2 ) , ( 1 , 2 , 3 , 2 , 1 ) , ( 3 , 3 , 2 , 1 ) , + ( 3 , 3 , 1 , 1 , 1 ) , (1 , 1 , 1 , 1 , 1 , 1, 1, 2) ) ; +#we now permutate these combinations and form substrings , that is numbers +#accordingly, preserving the order of digits + +#the dispatcher helps to select the right list comprehension depending on +#length of the @numbers array! +my %dispatcher = + 4 => &testSubSequences_4 , + 5 => &testSubSequences_5 , + 6 => &testSubSequences_6 , + 7 => &testSubSequences_7 , + 8 => &testSubSequences_8 ; + +say "+ and - can be inserted in the following ways:" ; +for @likelyCombos -> $combo { + my $selectedOp = %dispatcher{ $combo.elems } ; + my @permus = $combo.permutations.unique(:with(&[eqv])) ; + for @permus -> $permutation { + my @numbers = findNumbers( $digits , $permutation ) ; + $selectedOp( @numbers ) ; + } +} diff --git a/challenge-044/ulrich-rieke/raku/ch-2.p6 b/challenge-044/ulrich-rieke/raku/ch-2.p6 new file mode 100644 index 0000000000..86225bbbc1 --- /dev/null +++ b/challenge-044/ulrich-rieke/raku/ch-2.p6 @@ -0,0 +1,20 @@ +use v6 ; + +sub doublingSteps( Int $n is copy ) { + my $count = 0 ; + while ( $n < 200 ) { + $count++ ; + $n *= 2 ; + } + return ( $n div= 2 , --$count ) ; +} + +#we assume that we go to a starting point in steps of 1 , then +#keep doubling and then move forward to 200 in steps of 1 +sub computeSteps( Int $n is copy --> Int ) { + my @result = doublingSteps( $n ) ; + return ( $n - 1 + @result[1] + 200 - @result[0] ) ; +} + +my $moves = (1..100).map( { computeSteps( $_ ) } ).sort( {$^a <=> $^b})[0] ; +say "The minimum number of moves is $moves!" ; diff --git a/stats/pwc-current.json b/stats/pwc-current.json index b3905e6615..d491d7c46c 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -2,93 +2,20 @@ "xAxis" : { "type" : "category" }, - "series" : [ - { - "data" : [ - { - "name" : "Andrezgz", - "y" : 2, - "drilldown" : "Andrezgz" - }, - { - "name" : "Daniel Mantovani", - "y" : 2, - "drilldown" : "Daniel Mantovani" - }, - { - "drilldown" : "Dave Jacoby", - "y" : 2, - "name" : "Dave Jacoby" - }, - { - "name" : "Duane Powell", - "drilldown" : "Duane Powell", - "y" : 2 - }, - { - "drilldown" : "E. Choroba", - "y" : 2, - "name" : "E. Choroba" - }, - { - "drilldown" : "Luca Ferrari", - "y" : 2, - "name" : "Luca Ferrari" - }, - { - "y" : 2, - "drilldown" : "Markus Holzer", - "name" : "Markus Holzer" - }, - { - "y" : 1, - "drilldown" : "Peter Scott", - "name" : "Peter Scott" - }, - { - "drilldown" : "Roger Bell West", - "y" : 4, - "name" : "Roger Bell West" - }, - { - "name" : "Saif Ahmed", - "drilldown" : "Saif Ahmed", - "y" : 2 - }, - { - "y" : 2, - "drilldown" : "Simon Proctor", - "name" : "Simon Proctor" - }, - { - "name" : "Wanderdoc", - "y" : 2, - "drilldown" : "Wanderdoc" - } - ], - "colorByPoint" : 1, - "name" : "Perl Weekly Challenge - 044" - } - ], "plotOptions" : { "series" : { + "borderWidth" : 0, "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - }, - "borderWidth" : 0 + "format" : "{point.y}", + "enabled" : 1 + } } }, - "subtitle" : { - "text" : "[Champions: 12] Last updated at 2020-01-24 20:43:37 GMT" - }, - "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/>" + "chart" : { + "type" : "column" }, - "legend" : { - "enabled" : 0 + "title" : { + "text" : "Perl Weekly Challenge - 044" }, "drilldown" : { "series" : [ @@ -103,34 +30,34 @@ "id" : "Andrezgz" }, { + "name" : "Daniel Mantovani", + "id" : "Daniel Mantovani", "data" : [ [ "Perl", 2 ] - ], - "id" : "Daniel Mantovani", - "name" : "Daniel Mantovani" + ] }, { - "name" : "Dave Jacoby", - "id" : "Dave Jacoby", "data" : [ [ "Perl", 2 ] - ] + ], + "id" : "Dave Jacoby", + "name" : "Dave Jacoby" }, { "name" : "Duane Powell", - "id" : "Duane Powell", "data" : [ [ "Perl", 2 ] - ] + ], + "id" : "Duane Powell" }, { "name" : "E. Choroba", @@ -143,34 +70,34 @@ "id" : "E. Choroba" }, { + "name" : "Luca Ferrari", + "id" : "Luca Ferrari", "data" : [ [ "Raku", 2 ] - ], - "id" : "Luca Ferrari", - "name" : "Luca Ferrari" + ] }, { + "name" : "Markus Holzer", "id" : "Markus Holzer", "data" : [ [ "Raku", 2 ] - ], - "name" : "Markus Holzer" + ] }, { - "name" : "Peter Scott", - "id" : "Peter Scott", "data" : [ [ "Perl", 1 ] - ] + ], + "id" : "Peter Scott", + "name" : "Peter Scott" }, { "name" : "Roger Bell West", @@ -187,34 +114,44 @@ "id" : "Roger Bell West" }, { + "name" : "Saif Ahmed", "id" : "Saif Ahmed", "data" : [ [ "Perl", 2 ] + ] + }, + { + "id" : "Simon Proctor", + "data" : [ + [ + "Raku", + 2 + ] ], - "name" : "Saif Ahmed" + "name" : "Simon Proctor" }, { - "name" : "Simon Proctor", + "name" : "Ulrich Rieke", "data" : [ [ "Raku", 2 ] ], - "id" : "Simon Proctor" + "id" : "Ulrich Rieke" }, { - "name" : "Wanderdoc", "id" : "Wanderdoc", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Wanderdoc" } ] }, @@ -223,10 +160,88 @@ "text" : "Total Solutions" } }, - "chart" : { - "type" : "column" + "legend" : { + "enabled" : 0 }, - "title" : { - "text" : "Perl Weekly Challenge - 044" + "series" : [ + { + "data" : [ + { + "name" : "Andrezgz", + "drilldown" : "Andrezgz", + "y" : 2 + }, + { + "y" : 2, + "name" : "Daniel Mantovani", + "drilldown" : "Daniel Mantovani" + }, + { + "y" : 2, + "drilldown" : "Dave Jacoby", + "name" : "Dave Jacoby" + }, + { + "y" : 2, + "name" : "Duane Powell", + "drilldown" : "Duane Powell" + }, + { + "y" : 2, + "name" : "E. Choroba", + "drilldown" : "E. Choroba" + }, + { + "y" : 2, + "name" : "Luca Ferrari", + "drilldown" : "Luca Ferrari" + }, + { + "drilldown" : "Markus Holzer", + "name" : "Markus Holzer", + "y" : 2 + }, + { + "y" : 1, + "name" : "Peter Scott", + "drilldown" : "Peter Scott" + }, + { + "y" : 4, + "drilldown" : "Roger Bell West", + "name" : "Roger Bell West" + }, + { + "name" : "Saif Ahmed", + "drilldown" : "Saif Ahmed", + "y" : 2 + }, + { + "y" : 2, + "drilldown" : "Simon Proctor", + "name" : "Simon Proctor" + }, + { + "drilldown" : "Ulrich Rieke", + "name" : "Ulrich Rieke", + "y" : 2 + }, + { + "name" : "Wanderdoc", + "drilldown" : "Wanderdoc", + "y" : 2 + } + ], + "colorByPoint" : 1, + "name" : "Perl Weekly Challenge - 044" + } + ], + "subtitle" : { + "text" : "[Champions: 13] Last updated at 2020-01-24 21:12:06 GMT" + }, + "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/>" } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 3459643144..ebcedee52b 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,37 +1,30 @@ { - "legend" : { - "enabled" : "false" - }, - "subtitle" : { - "text" : "Last updated at 2020-01-24 20:43:37 GMT" + "xAxis" : { + "type" : "category", + "labels" : { + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + } + } }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" + "chart" : { + "type" : "column" }, "title" : { "text" : "Perl Weekly Challenge Contributions [2019 - 2020]" }, "yAxis" : { + "min" : 0, "title" : { "text" : null - }, - "min" : 0 - }, - "chart" : { - "type" : "column" + } }, - "xAxis" : { - "labels" : { - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - } - }, - "type" : "category" + "legend" : { + "enabled" : "false" }, "series" : [ { - "name" : "Contributions", "data" : [ [ "Blog", @@ -43,21 +36,28 @@ ], [ "Raku", - 1078 + 1080 ] ], + "name" : "Contributions", "dataLabels" : { - "color" : "#FFFFFF", - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - }, "align" : "right", - "rotation" : -90, "enabled" : "true", + "color" : "#FFFFFF", + "rotation" : -90, "y" : 10, - "format" : "{point.y:.0f}" + "format" : "{point.y:.0f}", + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + } } } - ] + ], + "subtitle" : { + "text" : "Last updated at 2020-01-24 21:12:06 GMT" + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 7d06200230..d9736d44a7 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,7 +1,24 @@ { + "chart" : { + "type" : "column" + }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + } + } + }, + "xAxis" : { + "type" : "category" + }, "drilldown" : { "series" : [ { + "name" : "001", + "id" : "001", "data" : [ [ "Perl", @@ -15,12 +32,9 @@ "Blog", 11 ] - ], - "id" : "001", - "name" : "001" + ] }, { - "id" : "002", "data" : [ [ "Perl", @@ -35,11 +49,11 @@ 10 ] ], + "id" : "002", "name" : "002" }, { "name" : "003", - "id" : "003", "data" : [ [ "Perl", @@ -53,11 +67,10 @@ "Blog", 9 ] - ] + ], + "id" : "003" }, { - "name" : "004", - "id" : "004", "data" : [ [ "Perl", @@ -71,7 +84,9 @@ "Blog", 10 ] - ] + ], + "id" : "004", + "name" : "004" }, { "id" : "005", @@ -110,7 +125,7 @@ "id" : "006" }, { - "id" : "007", + "name" : "007", "data" : [ [ "Perl", @@ -125,7 +140,7 @@ 10 ] ], - "name" : "007" + "id" : "007" }, { "id" : "008", @@ -146,6 +161,7 @@ "name" : "008" }, { + "name" : "009", "data" : [ [ "Perl", @@ -160,11 +176,9 @@ 13 ] ], - "id" : "009", - "name" : "009" + "id" : "009" }, { - "id" : "010", "data" : [ [ "Perl", @@ -179,11 +193,10 @@ 11 ] ], + "id" : "010", "name" : "010" }, { - "name" : "011", - "id" : "011", "data" : [ [ "Perl", @@ -197,7 +210,9 @@ "Blog", 10 ] - ] + ], + "id" : "011", + "name" : "011" }, { "name" : "012", @@ -237,6 +252,7 @@ }, { "name" : "014", + "id" : "014", "data" : [ [ "Perl", @@ -250,11 +266,10 @@ "Blog", 15 ] - ], - "id" : "014" + ] }, { - "name" : "015", + "id" : "015", "data" : [ [ "Perl", @@ -269,7 +284,7 @@ 15 ] ], - "id" : "015" + "name" : "015" }, { "data" : [ @@ -290,8 +305,6 @@ "name" : "016" }, { - "name" : "017", - "id" : "017", "data" : [ [ "Perl", @@ -305,9 +318,12 @@ "Blog", 12 ] - ] + ], + "id" : "017", + "name" : "017" }, { + "name" : "018", "data" : [ [ "Perl", @@ -322,10 +338,10 @@ 14 ] ], - "id" : "018", - "name" : "018" + "id" : "018" }, { + "name" : "019", "data" : [ [ "Perl", @@ -340,10 +356,11 @@ 13 ] ], - "id" : "019", - "name" : "019" + "id" : "019" }, { + "name" : "020", + "id" : "020", "data" : [ [ "Perl", @@ -357,13 +374,9 @@ "Blog", 13 ] - ], - "id" : "020", - "name" : "020" + ] }, { - "name" : "021", - "id" : "021", "data" : [ [ "Perl", @@ -377,7 +390,9 @@ "Blog", 10 ] - ] + ], + "id" : "021", + "name" : "021" }, { "name" : "022", @@ -398,7 +413,6 @@ "id" : "022" }, { - "id" : "023", "data" : [ [ "Perl", @@ -413,10 +427,10 @@ 12 ] ], + "id" : "023", "name" : "023" }, { - "id" : "024", "data" : [ [ "Perl", @@ -431,6 +445,7 @@ 11 ] ], + "id" : "024", "name" : "024" }, { @@ -452,7 +467,7 @@ "id" : "025" }, { - "name" : "026", + "id" : "026", "data" : [ [ "Perl", @@ -467,9 +482,10 @@ 10 ] ], - "id" : "026" + "name" : "026" }, { + "id" : "027", "data" : [ [ "Perl", @@ -484,11 +500,9 @@ 9 ] ], - "id" : "027", "name" : "027" }, { - "id" : "028", "data" : [ [ "Perl", @@ -503,11 +517,11 @@ 9 ] ], + "id" : "028", "name" : "028" }, { "name" : "029", - "id" : "029", "data" : [ [ "Perl", @@ -521,9 +535,11 @@ "Blog", 12 ] - ] + ], + "id" : "029" }, { + "id" : "030", "data" : [ [ "Perl", @@ -538,7 +554,6 @@ 10 ] ], - "id" : "030", "name" : "030" }, { @@ -561,7 +576,6 @@ }, { "name" : "032", - "id" : "032", "data" : [ [ "Perl", @@ -575,10 +589,10 @@ "Blog", 10 ] - ] + ], + "id" : "032" }, { - "name" : "033", "id" : "033", "data" : [ [ @@ -593,9 +607,11 @@ "Blog", 10 ] - ] + ], + "name" : "033" }, { + "id" : "034", "data" : [ [ "Perl", @@ -610,11 +626,9 @@ 11 ] ], - "id" : "034", "name" : "034" }, { - "name" : "035", "id" : "035", "data" : [ [ @@ -629,10 +643,11 @@ "Blog", 9 ] - ] + ], + "name" : "035" }, { - "id" : "036", + "name" : "036", "data" : [ [ "Perl", @@ -647,10 +662,9 @@ 10 ] ], - "name" : "036" + "id" : "036" }, { - "name" : "037", "data" : [ [ "Perl", @@ -665,7 +679,8 @@ 9 ] ], - "id" : "037" + "id" : "037", + "name" : "037" }, { "id" : "038", @@ -686,7 +701,6 @@ "name" : "038" }, { - "name" : "039", "id" : "039", "data" : [ [ @@ -701,10 +715,10 @@ "Blog", 12 ] - ] + ], + "name" : "039" }, { - "id" : "040", "data" : [ [ "Perl", @@ -719,6 +733,7 @@ 9 ] ], + "id" : "040", "name" : "040" }, { @@ -740,7 +755,7 @@ |
