diff options
23 files changed, 1999 insertions, 1691 deletions
diff --git a/challenge-196/ulrich-rieke/cpp/ch-2.cpp b/challenge-196/ulrich-rieke/cpp/ch-2.cpp new file mode 100644 index 0000000000..8545530a9a --- /dev/null +++ b/challenge-196/ulrich-rieke/cpp/ch-2.cpp @@ -0,0 +1,65 @@ +#include <iostream> +#include <vector> +#include <string> + +std::vector<std::string> split( const std::string & startline , const std::string & sep ) { + std::vector<std::string> separated ; + std::string::size_type start { 0 } ; + std::string::size_type pos ; + do { + pos = startline.find_first_of( sep , start ) ; + separated.push_back( startline.substr(start , pos - start )) ; + start = pos + 1 ; + } while ( pos != std::string::npos ) ; + return separated ; +} + +int findEnd( const std::vector<int> & array , int pos ) { + int current_index = pos ; + current_index++ ; + if ( current_index > array.size( ) - 1 ) { + return pos ; + } + else { + int current_number = array[ current_index ] ; + while ( current_number - array[ current_index - 1 ] == 1 ) { + current_index++ ; + if ( current_index < array.size( ) ) + current_number = array[ current_index ] ; + else + break ; + } + current_index-- ; + return current_index ; + } +} + +int main( ) { + std::cout << "Please enter a sorted array of unique integers!\n" ; + std::string line ; + std::getline( std::cin , line ) ; + std::vector<std::string> numberstrings( split( line , " " ) ) ; + std::vector<int> numbers ; + for ( auto & s : numberstrings ) { + numbers.push_back( std::stoi( s ) ) ; + } + std::vector<int> subarray ; + std::vector<std::vector<int>> continuousRuns ; + int pos = 0 ; + while ( pos < numbers.size( ) ) { + int end = findEnd( numbers , pos ) ; + if ( end - pos > 0 ) { + subarray.push_back( numbers[ pos ] ) ; + subarray.push_back( numbers[ end ] ) ; + continuousRuns.push_back( subarray ) ; + subarray.clear( ) ; + } + pos = end + 1 ; + } + for ( const auto & suba : continuousRuns ) { + std::cout << '[' << suba[0] << ',' << suba[1] << ']' ; + std::cout << " ," ; + } + std::cout << std::endl ; + return 0 ; +} diff --git a/challenge-196/ulrich-rieke/haskell/ch-1.hs b/challenge-196/ulrich-rieke/haskell/ch-1.hs new file mode 100644 index 0000000000..410736c9a8 --- /dev/null +++ b/challenge-196/ulrich-rieke/haskell/ch-1.hs @@ -0,0 +1,15 @@ +module Challenge196 + where +import Data.List ( subsequences , (!!) ) + +myRule :: [Int] -> Bool +myRule list = length list == 3 && (((list !! 0 ) < ( list !! 2 )) && +((list !! 2 ) < ( list !! 1 ))) + +solution :: [Int] -> [Int] +solution list + |not $ null solutionlist = head solutionlist + |otherwise = [] + where + solutionlist :: [[Int]] + solutionlist = filter myRule $ subsequences list diff --git a/challenge-196/ulrich-rieke/perl/ch-1.pl b/challenge-196/ulrich-rieke/perl/ch-1.pl new file mode 100644 index 0000000000..35a9c50b7b --- /dev/null +++ b/challenge-196/ulrich-rieke/perl/ch-1.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl ; +use strict ; +use warnings ; +use feature 'say' ; +use Algorithm::Combinatorics qw ( combinations ) ; + +sub myRule { + my $array = shift ; + return ($array->[0] < $array->[2]) && ( $array->[2] < $array->[1] ) ; +} + +say "Enter a list of integers, separated by blanks!" ; +my $line = <STDIN> ; +chomp $line ; +my @numbers = split( /\s/ , $line ) ; +my @allCombis ; +my $iter = combinations( \@numbers , 3 ) ; +while ( my $c = $iter->next ) { + if ( myRule( $c ) ) { + push @allCombis , $c ; + } +} +if ( scalar( @allCombis ) > 0 ) { + say "(" . join( ',' , @{$allCombis[0]} ) . ")" ; +} +else { + say "()" ; +} diff --git a/challenge-196/ulrich-rieke/perl/ch-2.pl b/challenge-196/ulrich-rieke/perl/ch-2.pl new file mode 100644 index 0000000000..cfaaff4c7c --- /dev/null +++ b/challenge-196/ulrich-rieke/perl/ch-2.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl ; +use strict ; +use warnings ; +use feature 'say' ; + +sub findEnd { + my $array = shift ; + my $pos = shift ; + my $current_index = $pos ; + $current_index++ ; + if ( $current_index > scalar( @{$array} ) - 1 ) { + return $pos ; + } + else { + my $current = $array->[ $current_index ] ; + while ( $current - $array->[ $current_index - 1 ] == 1 ) { + $current_index++ ; + if ( $current_index < scalar( @{$array} )) { + $current = $array->[ $current_index ] ; + } + else { + last ; + } + } + $current_index-- ; + return $current_index ; + } +} + +say "Please enter a sorted array of unique integers!" ; +my $line = <STDIN> ; +chomp $line ; +my @numbers = split( /\s/ , $line ) ; +my %numberFreq ; +map { $numberFreq{ $_ }++ } @numbers ; +my @sorted = sort { $a <=> $b } @numbers ; +if ( @sorted != @numbers || scalar( keys %numberFreq ) != scalar( @numbers ) ) { + say "Please enter a sorted array of unique numbers!" ; + $line = <STDIN> ; + chomp $line ; + @numbers = split( /\s/ , $line ) ; +} +my @subsequences ; +my $pos = 0 ; +my $len = scalar( @numbers ) ; +while ( $pos < $len - 1 ) { + my $end = findEnd( \@numbers, $pos ) ; + if ( $end - $pos > 0 ) { + push( @subsequences , [ $numbers[ $pos ] , $numbers[ $end ] ] ) ; + } + $pos = $end + 1 ; +} +say join( ',' , map { "[" . join( ',' , @{$_} ) . "]" } @subsequences ) ; diff --git a/challenge-196/ulrich-rieke/raku/ch-1.raku b/challenge-196/ulrich-rieke/raku/ch-1.raku new file mode 100644 index 0000000000..f3cba0a140 --- /dev/null +++ b/challenge-196/ulrich-rieke/raku/ch-1.raku @@ -0,0 +1,17 @@ +use v6 ; + +sub myRule( $aSeq ) { + return $aSeq[0] < $aSeq[2] && $aSeq[2] < $aSeq[1] ; +} + +say "Enter some integers , separated by a blank!" ; +my $line = $*IN.get ; +my @numbers = $line.split( /\s/ ).map( { .Int} ) ; +my @combis = @numbers.combinations: 3 ; +my @selected = @combis.grep( { myRule( $_ ) } ) ; +if ( @selected.elems > 0 ) { + say @selected[ 0 ] ; +} +else { + say "()" ; +} diff --git a/challenge-196/ulrich-rieke/raku/ch-2.raku b/challenge-196/ulrich-rieke/raku/ch-2.raku new file mode 100644 index 0000000000..ad3e7f41da --- /dev/null +++ b/challenge-196/ulrich-rieke/raku/ch-2.raku @@ -0,0 +1,40 @@ +use v6 ; + +sub findEnd( @numbers , $start ) { + my $current = $start ; + my $len = @numbers.elems ; + $current = $start + 1 ; + if ( $current == $len ) { + return $start ; + } + else { + while ( @numbers[ $current ] - @numbers[ $current - 1 ] == 1 ) { + $current++ ; + if ( $current == $len ) { + last ; + } + } + $current-- ; + return $current ; + } +} + +say "Please enter a sorted array of integers, each unique!" ; +my $line = $*IN.get ; +my @numbers = $line.split( /\s/ ).map( {.Int} ) ; +my @sorted = @numbers.sort( {$^a <=> $^b} ) ; +while ( @sorted != @numbers || @numbers.elems != @numbers.Set.elems ) { + say "Please enter a sorted array of unique numbers!" ; + $line = $*IN.get ; + @numbers = $line.split( /\s/ ).map( {.Int} ) ; +} +my $pos = 0 ; +my @subsequences ; +while ($pos < @numbers.elems - 1) { + my $end = findEnd( @numbers , $pos ) ; + if ( $end - $pos > 0 ) { + @subsequences.push( [@numbers[ $pos ] , @numbers[ $end ] ] ) ; + } + $pos = $end + 1 ; +} +@subsequences.map( { "[" ~ $_.join( ',' ) ~ "]" } ).join( ',' ).say ; diff --git a/challenge-196/ulrich-rieke/rust/ch-1.rs b/challenge-196/ulrich-rieke/rust/ch-1.rs new file mode 100644 index 0000000000..89a23aefa7 --- /dev/null +++ b/challenge-196/ulrich-rieke/rust/ch-1.rs @@ -0,0 +1,28 @@ +use std::io ; +use itertools::Itertools ; + +fn my_rule( the_vec : &Vec<i32> ) -> bool { + the_vec[0] < the_vec[ 2 ] && the_vec[2] < the_vec[ 1 ] +} + +fn main() { + println!("Enter a number of integers, separated by blanks!") ; + let mut inline : String = String::new( ) ; + io::stdin( ).read_line( &mut inline ).unwrap( ) ; + let entered_line : &str = &*inline ; + let numbers : Vec<i32> = entered_line.split_whitespace( ).map( | s | + s.trim( ).parse::<i32>( ).unwrap( ) ).collect( ) ; + let mut selected : Vec<Vec<i32>> = Vec::new( ) ; + let mut the_combis = numbers.into_iter( ).combinations( 3 ) ; + while let Some( combi ) = the_combis.next( ) { + if my_rule( &combi ) { + selected.push( combi ) ; + } + } + if selected.len( ) > 0 { + println!("{:?}" , selected[0] ) ; + } + else { + println!("()" ) ; + } +} diff --git a/challenge-196/ulrich-rieke/rust/ch-2.rs b/challenge-196/ulrich-rieke/rust/ch-2.rs new file mode 100644 index 0000000000..44a82b63be --- /dev/null +++ b/challenge-196/ulrich-rieke/rust/ch-2.rs @@ -0,0 +1,43 @@ +use std::io ; + +fn find_end( start : usize , subvec : &Vec<i32> ) -> usize { + let mut current_index : usize = start ; + current_index += 1 ; + if current_index > subvec.len( ) - 1 { + start + } + else { + let mut current_val : i32 = subvec[ current_index ] ; + while current_val - subvec[ current_index - 1] == 1 { + current_index += 1 ; + if current_index < subvec.len( ) { + current_val = subvec[ current_index ] ; + } + else { + break ; + } + } + current_index -= 1 ; + current_index + } +} + +fn main() { + println!("Please enter a sorted array of unique integers!") ; + let mut inline : String = String::new( ) ; + io::stdin( ).read_line( &mut inline ).unwrap( ) ; + let entered_line : &str = &*inline ; + let array : Vec<i32> = entered_line.split_whitespace( ).map( | s | + s.trim( ).parse::<i32>( ).unwrap( )).collect( ) ; + let mut subsequences : Vec<Vec<i32>> = Vec::new( ) ; + let mut pos : usize = 0 ; + while pos < array.len( ) - 1 { + let end = find_end( pos , &array ) ; + if end - pos > 0 { + let subarray = vec![array[pos] , array[end]] ; + subsequences.push( subarray ) ; + } + pos = end + 1 ; + } + println!("{:?}" , subsequences ) ; +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index e58d853a90..02c380c172 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,47 +1,122 @@ { - "legend" : { - "enabled" : 0 + "chart" : { + "type" : "column" }, - "plotOptions" : { - "series" : { - "borderWidth" : 0, - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - } - } + "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/>" }, + "series" : [ + { + "data" : [ + { + "y" : 2, + "name" : "Bob Lied", + "drilldown" : "Bob Lied" + }, + { + "drilldown" : "Carlos Oliveira", + "name" : "Carlos Oliveira", + "y" : 2 + }, + { + "name" : "Dave Jacoby", + "drilldown" : "Dave Jacoby", + "y" : 3 + }, + { + "y" : 2, + "name" : "David Ferrone", + "drilldown" : "David Ferrone" + }, + { + "y" : 3, + "name" : "James Smith", + "drilldown" : "James Smith" + }, + { + "y" : 8, + "name" : "Luca Ferrari", + "drilldown" : "Luca Ferrari" + }, + { + "y" : 2, + "drilldown" : "Mark Anderson", + "name" : "Mark Anderson" + }, + { + "drilldown" : "Niels van Dijke", + "name" : "Niels van Dijke", + "y" : 2 + }, + { + "y" : 3, + "name" : "Peter Campbell Smith", + "drilldown" : "Peter Campbell Smith" + }, + { + "y" : 4, + "drilldown" : "Roger Bell_West", + "name" : "Roger Bell_West" + }, + { + "drilldown" : "Thomas Kohler", + "name" : "Thomas Kohler", + "y" : 3 + }, + { + "y" : 4, + "name" : "Ulrich Rieke", + "drilldown" : "Ulrich Rieke" + }, + { + "y" : 3, + "name" : "W. Luis Mochan", + "drilldown" : "W. Luis Mochan" + } + ], + "colorByPoint" : 1, + "name" : "The Weekly Challenge - 196" + } + ], "title" : { "text" : "The Weekly Challenge - 196" }, - "chart" : { - "type" : "column" + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "xAxis" : { + "type" : "category" + }, + "legend" : { + "enabled" : 0 }, "drilldown" : { "series" : [ { "id" : "Bob Lied", - "name" : "Bob Lied", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Bob Lied" }, { + "name" : "Carlos Oliveira", "data" : [ [ "Perl", 2 ] ], - "id" : "Carlos Oliveira", - "name" : "Carlos Oliveira" + "id" : "Carlos Oliveira" }, { - "name" : "Dave Jacoby", - "id" : "Dave Jacoby", "data" : [ [ "Perl", @@ -51,21 +126,23 @@ "Blog", 1 ] - ] + ], + "id" : "Dave Jacoby", + "name" : "Dave Jacoby" }, { - "name" : "David Ferrone", "id" : "David Ferrone", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "David Ferrone" }, { - "id" : "James Smith", "name" : "James Smith", + "id" : "James Smith", "data" : [ [ "Perl", @@ -78,8 +155,6 @@ ] }, { - "id" : "Luca Ferrari", - "name" : "Luca Ferrari", "data" : [ [ "Raku", @@ -89,7 +164,9 @@ "Blog", 6 ] - ] + ], + "id" : "Luca Ferrari", + "name" : "Luca Ferrari" }, { "data" : [ @@ -102,16 +179,17 @@ "name" : "Mark Anderson" }, { + "id" : "Niels van Dijke", "data" : [ [ "Perl", 2 ] ], - "id" : "Niels van Dijke", "name" : "Niels van Dijke" }, { + "id" : "Peter Campbell Smith", "data" : [ [ "Perl", @@ -122,10 +200,10 @@ 1 ] ], - "id" : "Peter Campbell Smith", "name" : "Peter Campbell Smith" }, { + "id" : "Roger Bell_West", "data" : [ [ "Perl", @@ -136,12 +214,9 @@ 2 ] ], - "name" : "Roger Bell_West", - "id" : "Roger Bell_West" + "name" : "Roger Bell_West" }, { - "name" : "Thomas Kohler", - "id" : "Thomas Kohler", "data" : [ [ "Perl", @@ -151,9 +226,26 @@ "Blog", 1 ] + ], + "id" : "Thomas Kohler", + "name" : "Thomas Kohler" + }, + { + "name" : "Ulrich Rieke", + "id" : "Ulrich Rieke", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] ] }, { + "name" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -164,93 +256,20 @@ 1 ] ], - "id" : "W. Luis Mochan", - "name" : "W. Luis Mochan" + "id" : "W. Luis Mochan" } ] }, - "subtitle" : { - "text" : "[Champions: 12] Last updated at 2022-12-20 09:49:19 GMT" - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + } } }, - "xAxis" : { - "type" : "category" - }, - "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/>" - }, - "series" : [ - { - "name" : "The Weekly Challenge - 196", - "colorByPoint" : 1, - "data" : [ - { - "name" : "Bob Lied", - "drilldown" : "Bob Lied", - "y" : 2 - }, - { - "drilldown" : "Carlos Oliveira", - "name" : "Carlos Oliveira", - "y" : 2 - }, - { - "name" : "Dave Jacoby", - "drilldown" : "Dave Jacoby", - "y" : 3 - }, - { - "y" : 2, - "name" : "David Ferrone", - "drilldown" : "David Ferrone" - }, - { - "y" : 3, - "name" : "James Smith", - "drilldown" : "James Smith" - }, - { - "drilldown" : "Luca Ferrari", - "name" : "Luca Ferrari", - "y" : 8 - }, - { - "y" : 2, - "drilldown" : "Mark Anderson", - "name" : "Mark Anderson" - }, - { - "drilldown" : "Niels van Dijke", - "name" : "Niels van Dijke", - "y" : 2 - }, - { - "y" : 3, - "drilldown" : "Peter Campbell Smith", - "name" : "Peter Campbell Smith" - }, - { - "y" : 4, - "drilldown" : "Roger Bell_West", - "name" : "Roger Bell_West" - }, - { - "name" : "Thomas Kohler", - "drilldown" : "Thomas Kohler", - "y" : 3 - }, - { - "drilldown" : "W. Luis Mochan", - "name" : "W. Luis Mochan", - "y" : 3 - } - ] - } - ] + "subtitle" : { + "text" : "[Champions: 13] Last updated at 2022-12-20 14:02:35 GMT" + } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 5613699791..bbc92538c9 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,18 +1,36 @@ { + "subtitle" : { + "text" : "Last updated at 2022-12-20 14:02:35 GMT" + }, + "yAxis" : { + "min" : 0, + "title" : { + "text" : null + } + }, + "xAxis" : { + "labels" : { + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + } + }, + "type" : "category" + }, + "legend" : { + "enabled" : "false" + }, + "chart" : { + "type" : "column" + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "title" : { + "text" : "The Weekly Challenge Contributions [2019 - 2022]" + }, "series" : [ { - "dataLabels" : { - "format" : "{point.y:.0f}", - "align" : "right", - "enabled" : "true", - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - }, - "rotation" : -90, - "color" : "#FFFFFF", - "y" : 10 - }, "data" : [ [ "Blog", @@ -20,44 +38,26 @@ ], [ "Perl", - 9618 + 9620 ], [ "Raku", - 5761 + 5763 ] ], - "name" : "Contributions" - } - ], - "xAxis" : { - "type" : "category", - "labels" : { - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" + "name" : "Contributions", + "dataLabels" : { + "enabled" : "true", + "y" : 10, + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + }, + "align" : "right", + "rotation" : -90, + "format" : "{point.y:.0f}", + "color" : "#FFFFFF" } } - }, - "yAxis" : { - "min" : 0, - "title" : { - "text" : null - } - }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - }, - "chart" : { - "type" : "column" - }, - "title" : { - "text" : "The Weekly Challenge Contributions [2019 - 2022]" - }, - "subtitle" : { - "text" : "Last updated at 2022-12-20 09:49:19 GMT" - }, - "legend" : { - "enabled" : "false" - } + ] } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 81b8fd74a5..42529729b4 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,49 +1,37 @@ { - "xAxis" : { - "type" : "category" - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "tooltip" : { - "headerFormat" : "<span style=\"font-size:11px\"></span>", - "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>", - "followPointer" : "true" - }, "series" : [ { + "colorByPoint" : "true", "data" : [ { "y" : 161, - "drilldown" : "001", - "name" : "#001" + "name" : "#001", + "drilldown" : "001" }, { - "y" : 125, + "name" : "#002", "drilldown" : "002", - "name" : "#002" + "y" : 125 }, { - "y" : 83, "name" : "#003", - "drilldown" : "003" + "drilldown" : "003", + "y" : 83 }, { + "y" : 99, "drilldown" : "004", - "name" : "#004", - "y" : 99 + "name" : "#004" }, { - "name" : "#005", + "y" : 78, "drilldown" : "005", - "y" : 78 + "name" : "#005" }, { - "y" : 58, + "name" : "#006", "drilldown" : "006", - "name" : "#006" + "y" : 58 }, { "y" : 65, @@ -56,19 +44,19 @@ "drilldown" : "008" }, { + "y" : 76, "drilldown" : "009", - "name" : "#009", - "y" : 76 + "name" : "#009" }, { - "name" : "#010", "drilldown" : "010", + "name" : "#010", "y" : 65 }, { "y" : 85, - "name" : "#011", - "drilldown" : "011" + "drilldown" : "011", + "name" : "#011" }, { "y" : 89, @@ -77,32 +65,32 @@ }, { "y" : 85, - "drilldown" : "013", - "name" : "#013" + "name" : "#013", + "drilldown" : "013" }, { - "y" : 101, "name" : "#014", - "drilldown" : "014" + "drilldown" : "014", + "y" : 101 }, { - "y" : 99, + "name" : "#015", "drilldown" : "015", - "name" : "#015" + "y" : 99 }, { - "drilldown" : "016", + "y" : 71, "name" : "#016", - "y" : 71 + "drilldown" : "016" }, { - "y" : 84, "name" : "#017", - "drilldown" : "017" + "drilldown" : "017", + "y" : 84 }, { - "name" : "#018", "drilldown" : "018", + "name" : "#018", "y" : 81 }, { @@ -111,14 +99,14 @@ "drilldown" : "019" }, { + "y" : 101, "name" : "#020", - "drilldown" : "020", - "y" : 101 + "drilldown" : "020" }, { "y" : 72, - "name" : "#021", - "drilldown" : "021" + "drilldown" : "021", + "name" : "#021" }, { "y" : 68, @@ -136,9 +124,9 @@ "y" : 75 }, { - "y" : 59, + "drilldown" : "025", "name" : "#025", - "drilldown" : "025" + "y" : 59 }, { "drilldown" : "026", @@ -151,14 +139,14 @@ "y" : 62 }, { - "drilldown" : "028", + "y" : 82, "name" : "#028", - "y" : 82 + "drilldown" : "028" }, { + "y" : 81, "drilldown" : "029", - "name" : "#029", - "y" : 81 + "name" |
