diff options
| -rw-r--r-- | challenge-087/ulrich-rieke/haskell/ch-1.hs | 14 | ||||
| -rw-r--r-- | challenge-087/ulrich-rieke/perl/ch-1.pl | 51 | ||||
| -rw-r--r-- | challenge-087/ulrich-rieke/perl/ch-2.pl | 76 | ||||
| -rw-r--r-- | stats/pwc-current.json | 127 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 62 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 610 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 724 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 96 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 102 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 36 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 100 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 102 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 118 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 446 |
15 files changed, 1430 insertions, 1274 deletions
diff --git a/challenge-087/ulrich-rieke/haskell/ch-1.hs b/challenge-087/ulrich-rieke/haskell/ch-1.hs new file mode 100644 index 0000000000..98f26301e8 --- /dev/null +++ b/challenge-087/ulrich-rieke/haskell/ch-1.hs @@ -0,0 +1,14 @@ +module Challenge087 + where +import Data.List ( sort , sortOn , subsequences ) + +solution :: [Int] -> [Int] +solution list + |not $ null orderedSequences = last $ sortOn length orderedSequences + |otherwise = [] + where + sortedList :: [Int] + sortedList = sort list + orderedSequences :: [[Int]] + orderedSequences = filter (\li -> last li == (head li + length li - 1 ) ) + $ filter ( ( 1 < ) . length ) $ subsequences sortedList diff --git a/challenge-087/ulrich-rieke/perl/ch-1.pl b/challenge-087/ulrich-rieke/perl/ch-1.pl new file mode 100644 index 0000000000..8604044fdf --- /dev/null +++ b/challenge-087/ulrich-rieke/perl/ch-1.pl @@ -0,0 +1,51 @@ +#!/usr/bin/perl ; +use strict ; +use warnings ; + +sub enterArray { + my @ar ; + print "Enter integers, -1 to end!\n" ; + my $num = <STDIN> ; + chomp $num ; + while ( $num != -1 ) { + while ( $num !~ /\d+/ ) { + print "Wrong entry, please enter a number!\n" ; + $num = <STDIN> ; + chomp $num ; + } + push @ar , $num ; + $num = <STDIN> ; + chomp $num ; + } + return @ar ; +} + +my @array = enterArray( ) ; +my @sorted = sort { $a <=> $b } @array ;#sort to possibly get consecutive number +my $current = 0 ; +my @consecutiveRuns ; #there can be a number of different consecutive sequences +my $run = [] ; #holds the last run of consecutive numbers +while ( $current < scalar @array - 1 ) { + if ( ($sorted[ $current + 1 ] - $sorted[ $current ]) == 1 ) { + push @$run, ($sorted[ $current] , $sorted[ $current + 1 ] ) ; + $current += 2 ; + } + else { + if ( @$run ) {#if we had consecutive numbers we must add the current number + push @$run , $sorted[ $current ] ; + push @consecutiveRuns , $run ; #push the last run of consecutive numbers + $run = [] ; #start anew, empty the array reference for the next sequence + } + $current++ ; + } +} +my @sortedRuns = sort { scalar @$b <=> scalar @$a } @consecutiveRuns ; +if ( @sortedRuns ) { + my @longestRun = @{ $sortedRuns[ 0 ] } ; + print "(" ; + map { print "$_ " } @longestRun ; + print ")\n" ; +} +else { + print "0\n" ; +} diff --git a/challenge-087/ulrich-rieke/perl/ch-2.pl b/challenge-087/ulrich-rieke/perl/ch-2.pl new file mode 100644 index 0000000000..75f3c44f9a --- /dev/null +++ b/challenge-087/ulrich-rieke/perl/ch-2.pl @@ -0,0 +1,76 @@ +#!/usr/bin/perl ; +use strict ; +use warnings ; +use feature 'say' ; +use List::Util qw( all ) ; + +sub enterArray { + my ( $row, $cols ) = @_ ; + my @array ; + my $line ; + say "Enter rows consisting only of 0 and 1!" ; + for (0 .. $row - 1 ) { + $line = <STDIN> ; + chomp $line ; + while ( $line !~ /\A[01]+\Z/ ) { + say "line should only consist of 0 and 1! Enter a new line!" ; + $line = <STDIN> ; + chomp $line ; + } + push @array , $line ; + } + return @array ; +} + +#from any given point in the array, defined by the upper line and the upper +#left column, find a rectangle that is defined by $width and $depth +#we attach the characters that we find to a result string +#if it is a rectangle the result string contains only '1' + +sub findRectangle { + my ($array, $lineLeftUpper , $colLeftUpper, $width , $depth ) = @_ ; + my $result ; + for my $i ( 0 .. $width - 1 ) { + for my $j ( 0 .. $depth - 1 ) { + $result .= substr ($array->[$lineLeftUpper + $j] , $colLeftUpper + $i , 1 ) ; + } + } + if ( $result =~ /^1+$/ ) { + return [$width, $depth ] ; + } + else { + return [0 , 0 ] ; + } +} + +my $m = $ARGV[ 0 ] ; +my $n = $ARGV[ 1 ] ; +my @array = enterArray( $m , $n ) ; +my @rectangles ; +#for every point in the array with enough room left for a minimum rectangle of width +#2 and depth 2 , look for a possible rectangle originating at that point +#if they consist of 1 only store the corresponding width and depth ( right and down ) +#in the array @rectangles . In the end , sort this array in descending order with +#the product of width and depth as the sorting criterion +for my $rowUpperLeft (0 .. $m - 2 ) { + for my $colUpperLeft (0 .. $n - 2 ) { + for my $w (2 .. $n - $colUpperLeft ) { + for my $d (2 .. $m - $rowUpperLeft ) { + push @rectangles , findRectangle(\@array , $rowUpperLeft, $colUpperLeft , + $w , $d ) ; + } + } + } +} +if ( all { $_->[0] == 0 and $_->[1] == 0 } @rectangles ) { + say 0 ; +} +else { + my @sorted = sort { ($b->[1] * $b->[0]) <=> ($a->[0] * $a->[1] ) } @rectangles ; + my $outputline = '1' x $sorted[0]->[0] ; #the first el. of $sorted[0] holds the width + for (0 .. $sorted[0]->[1] - 1 ) { #print as many lines as depth indicates + print "[ " ; + map { print "$_ " } split (// , $outputline ) ; + print " ]\n" ; + } +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 92e6a9e776..7d22273e09 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,24 +1,29 @@ { + "subtitle" : { + "text" : "[Champions: 13] Last updated at 2020-11-18 21:55:52 GMT" + }, + "tooltip" : { + "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/>", + "followPointer" : 1 + }, "xAxis" : { "type" : "category" }, - "subtitle" : { - "text" : "[Champions: 12] Last updated at 2020-11-18 21:46:43 GMT" - }, - "title" : { - "text" : "Perl Weekly Challenge - 087" + "legend" : { + "enabled" : 0 }, "drilldown" : { "series" : [ { "id" : "Alexander Karelas", - "name" : "Alexander Karelas", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Alexander Karelas" }, { "data" : [ @@ -41,14 +46,14 @@ "id" : "Dave Jacoby" }, { + "id" : "Duane Powell", + "name" : "Duane Powell", "data" : [ [ "Perl", 1 ] - ], - "id" : "Duane Powell", - "name" : "Duane Powell" + ] }, { "id" : "E. Choroba", @@ -61,28 +66,28 @@ ] }, { - "name" : "Feng Chang", - "id" : "Feng Chang", "data" : [ [ "Raku", 2 ] - ] + ], + "name" : "Feng Chang", + "id" : "Feng Chang" }, { - "id" : "Lubos Kolouch", "name" : "Lubos Kolouch", "data" : [ [ "Perl", 1 ] - ] + ], + "id" : "Lubos Kolouch" }, { - "name" : "Mark Anderson", "id" : "Mark Anderson", + "name" : "Mark Anderson", "data" : [ [ "Raku", @@ -92,15 +97,16 @@ }, { "id" : "Philip Hood", - "name" : "Philip Hood", "data" : [ [ "Raku", 1 ] - ] + ], + "name" : "Philip Hood" }, { + "id" : "Roger Bell_West", "data" : [ [ "Perl", @@ -111,7 +117,6 @@ 2 ] ], - "id" : "Roger Bell_West", "name" : "Roger Bell_West" }, { @@ -131,38 +136,57 @@ 2 ] ], - "id" : "Stuart Little", - "name" : "Stuart Little" + "name" : "Stuart Little", + "id" : "Stuart Little" + }, + { + "id" : "Ulrich Rieke", + "name" : "Ulrich Rieke", + "data" : [ + [ + "Perl", + 2 + ] + ] } ] }, + "title" : { + "text" : "Perl Weekly Challenge - 087" + }, + "chart" : { + "type" : "column" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, "plotOptions" : { "series" : { "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" + "format" : "{point.y}", + "enabled" : 1 }, "borderWidth" : 0 } }, "series" : [ { - "name" : "Perl Weekly Challenge - 087", - "colorByPoint" : 1, "data" : [ { "y" : 2, - "drilldown" : "Alexander Karelas", - "name" : "Alexander Karelas" + "name" : "Alexander Karelas", + "drilldown" : "Alexander Karelas" }, { - "name" : "Andrew Shitov", + "y" : 2, "drilldown" : "Andrew Shitov", - "y" : 2 + "name" : "Andrew Shitov" }, { - "drilldown" : "Dave Jacoby", "name" : "Dave Jacoby", + "drilldown" : "Dave Jacoby", "y" : 2 }, { @@ -176,19 +200,19 @@ "drilldown" : "E. Choroba" }, { - "drilldown" : "Feng Chang", "name" : "Feng Chang", + "drilldown" : "Feng Chang", "y" : 2 }, { - "y" : 1, + "name" : "Lubos Kolouch", "drilldown" : "Lubos Kolouch", - "name" : "Lubos Kolouch" + "y" : 1 }, { "y" : 1, - "name" : "Mark Anderson", - "drilldown" : "Mark Anderson" + "drilldown" : "Mark Anderson", + "name" : "Mark Anderson" }, { "y" : 1, @@ -196,8 +220,8 @@ "name" : "Philip Hood" }, { - "name" : "Roger Bell_West", "drilldown" : "Roger Bell_West", + "name" : "Roger Bell_West", "y" : 4 }, { @@ -206,27 +230,18 @@ "drilldown" : "Simon Proctor" }, { - "drilldown" : "Stuart Little", + "y" : 2, "name" : "Stuart Little", - "y" : 2 + "drilldown" : "Stuart Little" + }, + { + "y" : 2, + "name" : "Ulrich Rieke", + "drilldown" : "Ulrich Rieke" } - ] - } - ], - "legend" : { - "enabled" : 0 - }, - "chart" : { - "type" : "column" - }, - "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/>" - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" + ], + "colorByPoint" : 1, + "name" : "Perl Weekly Challenge - 087" } - } + ] } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 902e800679..db5daf359c 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -2,35 +2,9 @@ "title" : { "text" : "Perl Weekly Challenge Contributions [2019 - 2020]" }, - "subtitle" : { - "text" : "Last updated at 2020-11-18 21:46:43 GMT" - }, - "xAxis" : { - "type" : "category", - "labels" : { - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - } - } - }, - "yAxis" : { - "title" : { - "text" : null - }, - "min" : 0 - }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - }, - "chart" : { - "type" : "column" - }, - "legend" : { - "enabled" : "false" - }, "series" : [ { + "name" : "Contributions", "data" : [ [ "Blog", @@ -38,26 +12,52 @@ ], [ "Perl", - 3853 + 3855 ], [ "Raku", 2498 ] ], - "name" : "Contributions", "dataLabels" : { "color" : "#FFFFFF", "enabled" : "true", "rotation" : -90, + "align" : "right", "format" : "{point.y:.0f}", "y" : 10, - "align" : "right", "style" : { "fontSize" : "13px", "fontFamily" : "Verdana, sans-serif" } } } - ] + ], + "yAxis" : { + "title" : { + "text" : null + }, + "min" : 0 + }, + "chart" : { + "type" : "column" + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "subtitle" : { + "text" : "Last updated at 2020-11-18 21:55:52 GMT" + }, + "legend" : { + "enabled" : "false" + }, + "xAxis" : { + "type" : "category", + "labels" : { + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + } + } + } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 3f483b24a6..56ae785c62 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,9 +1,22 @@ { + "subtitle" : { + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2020-11-18 21:55:52 GMT" + }, + "tooltip" : { + "followPointer" : "true", + "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>", + "headerFormat" : "<span style=\"font-size:11px\"></span>" + }, + "xAxis" : { + "type" : "category" + }, + "legend" : { + "enabled" : "false" + }, "drilldown" : { "series" : [ { "name" : "001", - "id" : "001", "data" : [ [ "Perl", @@ -17,9 +30,11 @@ "Blog", 11 ] - ] + ], + "id" : "001" }, { + "id" : "002", "data" : [ [ "Perl", @@ -34,10 +49,11 @@ 10 ] ], - "name" : "002", - "id" : "002" + "name" : "002" }, { + "id" : "003", + "name" : "003", "data" : [ [ "Perl", @@ -51,12 +67,9 @@ "Blog", 9 ] - ], - "id" : "003", - "name" : "003" + ] }, { - "id" : "004", "name" : "004", "data" : [ [ @@ -71,11 +84,11 @@ "Blog", 10 ] - ] + ], + "id" : "004" }, { "id" : "005", - "name" : "005", "data" : [ [ "Perl", @@ -89,9 +102,11 @@ "Blog", 12 ] - ] + ], + "name" : "005" }, { + "id" : "006", "data" : [ [ "Perl", @@ -106,11 +121,9 @@ 7 ] ], - "id" : "006", "name" : "006" }, { - "name" : "007", "id" : "007", "data" : [ [ @@ -125,11 +138,10 @@ "Blog", 10 ] - ] + ], + "name" : "007" }, { - "name" : "008", - "id" : "008", "data" : [ [ "Perl", @@ -143,10 +155,11 @@ "Blog", 12 ] - ] + ], + "name" : "008", + "id" : "008" }, { - "name" : "009", "id" : "009", "data" : [ [ @@ -161,7 +174,8 @@ "Blog", 13 ] - ] + ], + "name" : "009" }, { "id" : "010", @@ -182,8 +196,8 @@ ] }, { - "name" : "011", "id" : "011", + "name" : "011", "data" : [ [ "Perl", @@ -200,6 +214,7 @@ ] }, { + "id" : "012", "data" : [ [ "Perl", @@ -214,10 +229,11 @@ 11 ] ], - "name" : "012", - "id" : "012" + "name" : "012" }, { + "id" : "013", + "name" : "013", "data" : [ [ "Perl", @@ -231,13 +247,11 @@ "Blog", 13 ] - ], - "name" : "013", - "id" : "013" + ] }, { - "name" : "014", "id" : "014", + "name" : "014", "data" : [ [ "Perl", @@ -268,8 +282,8 @@ 15 ] ], - "id" : "015", - "name" : "015" + "name" : "015", + "id" : "015" }, { "data" : [ @@ -286,12 +300,11 @@ 12 ] ], - "id" : "016", - "name" : "016" + "name" : "016", + "id" : "016" }, { "name" : "017", - "id" : "017", "data" : [ [ "Perl", @@ -305,9 +318,11 @@ "Blog", 12 ] - ] + ], + "id" : "017" }, { + "name" : "018", "data" : [ [ "Perl", @@ -322,10 +337,10 @@ 14 ] ], - "id" : "018", - "name" : "018" + "id" : "018" }, { + "id" : "019", "data" : [ [ "Perl", @@ -340,11 +355,9 @@ 13 ] ], - "name" : "019", - "id" : "019" + "name" : "019" }, { - "name" : "020", "id" : "020", "data" : [ [ @@ -359,9 +372,12 @@ "Blog", 13 ] - ] + ], + "name" : "020" }, { + "id" : "021", + "name" : "021", "data" : [ [ "Perl", @@ -375,12 +391,9 @@ "Blog", 10 ] - ], - "name" : "021", - "id" : "021" + ] }, { - "id" : "022", "name" : "022", "data" : [ [ @@ -395,9 +408,11 @@ "Blog", 10 ] - ] + ], + "id" : "022" }, { + "name" : "023", "data" : [ [ "Perl", @@ -412,10 +427,11 @@ 12 ] ], - "id" : "023", - "name" : "023" + "id" : "023" }, { + "id" : "024", + "name" : "024", "data" : [ [ "Perl", @@ -429,9 +445,7 @@ "Blog", 11 ] - ], - "id" : "024", - "name" : "024" + ] }, { "id" : "025", @@ -452,8 +466,6 @@ ] }, { - "name" : "026", - "id" : "026", "data" : [ [ "Perl", @@ -467,9 +479,12 @@ "Blog", 10 ] - ] + ], + "name" : "026", + "id" : "026" }, { + "id" : "027", "data" : [ [ "Perl", @@ -484,7 +499,6 @@ 9 ] ], - "id" : "027", "name" : "027" }, { @@ -506,8 +520,6 @@ "id" : "028" }, { - "name" : "029", - "id" : "029", "data" : [ [ "Perl", @@ -521,11 +533,12 @@ "Blog", 12 ] - ] + ], + "name" : "029", + "id" : "029" }, { "name" : "030", - "id" : "030", "data" : [ [ "Perl", @@ -539,9 +552,11 @@ "Blog", 10 ] - ] + ], + "id" : "030" }, { + "name" : "031", "data" : [ [ "Perl", @@ -556,11 +571,9 @@ 9 ] ], - "name" : "031", "id" : "031" }, { - "name" : "032", "id" : "032", "data" : [ [ @@ -575,10 +588,10 @@ "Blog", 10 ] - ] + ], + "name" : "032" }, { - "id" : "033", "name" : "033", "data" : [ [ @@ -593,11 +606,10 @@ "Blog", 10 ] - ] + ], + "id" : "033" }, { - "name" : "034", - "id" : "034", "data" : [ [ "Perl", @@ -611,9 +623,13 @@ "Blog", 11 ] - ] + ], + "name" : "034", + "id" : "034" }, { + "id" : "035", + "name" : "035", "data" : [ [ "Perl", @@ -627,9 +643,7 @@ "Blog", 9 ] - ], - "name" : "035", - "id" : "035" + ] }, { "id" : "036", @@ -650,6 +664,8 @@ ] }, { + "id" : "037", + "name" : "037", "data" : [ [ "Perl", @@ -663,11 +679,10 @@ "Blog", 9 ] - ], - "name" : "037", - "id" : "037" + ] }, { + "name" : "038", "data" : [ [ "Perl", @@ -682,12 +697,9 @@ 12 ] ], - "name" : "038", "id" : "038" }, { - "id" : "039", - "name" : "039", "data" : [ [ "Perl", @@ -701,9 +713,13 @@ "Blog", 12 ] - ] + ], + "name" : "039", + "id" : "039" }, { + "id" : "040", + "name" : "040", "data" : [ [ "Perl", @@ -717,9 +733,7 @@ "Blog", 10 ] - ], - "name" : "040", - "id" : "040" + ] }, { "id" : "041", @@ -740,6 +754,7 @@ ] }, { + "name" : "042", "data" : [ [ "Perl", @@ -754,10 +769,10 @@ 11 ] ], - "name" : "042", "id" : "042" }, { + "name" : "043", "data" : [ [ "Perl", @@ -772,11 +787,9 @@ 11 ] ], - "id" : "043", - "name" : "043" + "id" : "043" }, { - "id" : "044", "name" : "044", "data" : [ [ @@ -791,11 +804,10 @@ "Blog", 11 ] - ] + ], + "id" : "044" }, { - "id" : "045", - "name" : "045", "data" : [ [ "Perl", @@ -809,11 +821,11 @@ "Blog", 11 ] - ] + ], + "name" : "045", + "id" : "045" }, { - "name" : "046", - "id" : "046", "data" : [ [ "Perl", @@ -827,9 +839,12 @@ "Blog", 10 ] - ] + ], + "name" : "046", + "id" : "046" }, { + "id" : "047", "data" : [ [ "Perl", @@ -844,12 +859,10 @@ 10 ] ], - "name" : "047", - "id" : "047" + "name" : "047" }, { "name" : "048", - "id" : "048", "data" : [ [ "Perl", @@ -863,9 +876,11 @@ "Blog", 12 ] - ] + ], + "id" : "048" }, { + "name" : "049", "data" : [ [ "Perl", @@ -880,12 +895,10 @@ 12 ] ], - "name" : "049", "id" : "049" }, { "id" : "050", - "name" : "050", "data" : [ [ "Perl", @@ -899,11 +912,10 @@ "Blog", |
