diff options
24 files changed, 1894 insertions, 1640 deletions
diff --git a/challenge-185/ulrich-rieke/cpp/ch-1.cpp b/challenge-185/ulrich-rieke/cpp/ch-1.cpp new file mode 100644 index 0000000000..244b482591 --- /dev/null +++ b/challenge-185/ulrich-rieke/cpp/ch-1.cpp @@ -0,0 +1,20 @@ +#include <iostream> +#include <string> + +int main( ) { + std::cout << "Please enter a MAC address in the form hhhh.hhhh.hhhh!\n" ; + std::string address ; + std::getline( std::cin , address ) ; + int pos = 0 ; + std::string output ; + while ( pos < address.length( ) - 2 ) { + output.append( address.substr( pos , 2 )) ; + output.append( ":" ) ; + pos += 2 ; + if ( address.substr( pos , 1 ) == "." ) + pos++ ; + } + //take the output substr because we want to leave out the final ':' + std::cout << output.substr(0 , output.length( ) - 1 ) << std::endl ; + return 0 ; +} diff --git a/challenge-185/ulrich-rieke/cpp/ch-2.cpp b/challenge-185/ulrich-rieke/cpp/ch-2.cpp new file mode 100644 index 0000000000..cc3d7b73ae --- /dev/null +++ b/challenge-185/ulrich-rieke/cpp/ch-2.cpp @@ -0,0 +1,45 @@ +#include <iostream> +#include <string> +#include <cctype> +#include <algorithm> +#include <vector> + +std::string substitute( const std::string & word ) { + std::string output ; + int count = 0 ; + int pos = 0 ; + while ( count < 4 ) { + if (std::isalnum( static_cast<int>(word[ pos ] )) != 0 ) { + output.append( "x") ; + pos++ ; + count++ ; + } + else { + output.append( word.substr( pos, 1 )) ; + pos++ ; + } + } + output.append( word.substr( pos )) ; + return output ; +} + +int main( ) { + std::cout << "Please enter codes with a minimum length of 4!\n" ; + std::cout << "Enter an empty string to end!\n" ; + std::vector<std::string> allInput ; + std::string line ; + std::getline( std::cin , line ) ; + while ( line.length( ) > 0 ) { + allInput.push_back( line ) ; + std::getline( std::cin , line ) ; + } + std::transform( allInput.begin( ) , allInput.end( ) , allInput.begin( ), + substitute ) ; + for ( auto & s : allInput ) { + std::cout << s ; + if ( s != allInput.back( ) ) + std::cout << " , " ; + } + std::cout << std::endl ; + return 0 ; +} diff --git a/challenge-185/ulrich-rieke/haskell/ch-1.hs b/challenge-185/ulrich-rieke/haskell/ch-1.hs new file mode 100644 index 0000000000..e17f5d9494 --- /dev/null +++ b/challenge-185/ulrich-rieke/haskell/ch-1.hs @@ -0,0 +1,16 @@ +module Challenge185 + where +import Data.List.Split ( splitOn ) +import Data.List ( intercalate ) + +miniconvert :: String -> String +miniconvert quad = take 2 quad ++ ":" ++ drop 2 quad + +convert :: String -> String +convert = intercalate ":" . map miniconvert . splitOn "." + +main :: IO ( ) +main = do + putStrLn "Enter a MAC address in the form hhhh.hhhh.hhhh!" + address <- getLine + putStrLn $ convert address diff --git a/challenge-185/ulrich-rieke/haskell/ch-2.hs b/challenge-185/ulrich-rieke/haskell/ch-2.hs new file mode 100644 index 0000000000..0fc9ad9faf --- /dev/null +++ b/challenge-185/ulrich-rieke/haskell/ch-2.hs @@ -0,0 +1,23 @@ +module Challenge185_2 + where +import Data.Char ( isAlpha, isDigit ) +import Data.List.Split ( splitOn ) +import Data.List ( findIndices ) + +step :: String -> String +step [] = [] +step (l:ls) + |not (l == 'x' ) && (isAlpha l || isDigit l) = 'x': ls + |otherwise = l : step ls + +convert :: String -> String +convert s = until myCondition step s +where + myCondition :: String -> Bool + myCondition st = (length $ findIndices (== 'x') st) == 4 + +main :: IO ( ) +main = do + putStrLn "Enter a number of codes, separated by a blank!" + inputline <- getLine + print $ map convert $ splitOn " " inputline diff --git a/challenge-185/ulrich-rieke/perl/ch-1.pl b/challenge-185/ulrich-rieke/perl/ch-1.pl new file mode 100644 index 0000000000..8d29925c1b --- /dev/null +++ b/challenge-185/ulrich-rieke/perl/ch-1.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl ; +use strict ; +use warnings ; +use feature 'say' ; + +say "Enter a MAC address in the form hhhh.hhhh.hhhh!" ; +my $address = <STDIN> ; +chomp $address ; +while ( $address !~ /\A(\w{4}\.){2}\w{4}\z/ ) { + say "The MAC address should have the form hhhh.hhhh.hhhh!" ; + $address = <STDIN> ; + chomp $address ; +} +my @parts = split( /\./ , $address ) ; +my @chunks ; +for my $part( @parts ) { + push @chunks , substr( $part , 0 , 2 ) ; + push @chunks, substr( $part , 2 , 2 ) ; +} +say join( ':' , @chunks ) ; diff --git a/challenge-185/ulrich-rieke/perl/ch-2.pl b/challenge-185/ulrich-rieke/perl/ch-2.pl new file mode 100644 index 0000000000..4752a93b7b --- /dev/null +++ b/challenge-185/ulrich-rieke/perl/ch-2.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl ; +use strict ; +use warnings ; +use feature 'say' ; + +sub mySubstitute { + my $word = shift ; + my $pos = 0 ; + my $count = 0 ; + while ( $count < 4 ) { + if ( substr( $word , $pos , 1 ) =~ /\w/ ) { + substr( $word, $pos , 1 ) = "x" ; + $count++ ; + $pos++ ; + } + else { + $pos++ ; + } + } + return $word ; +} + +say "Please enter some codes, separated by a blank!" ; +my $line = <STDIN> ; +chomp $line ; +my @codes = split( /\s/ , $line ) ; +my @changed = map { mySubstitute( $_ ) } @codes ; +say join ( ',' , @changed ) ; diff --git a/challenge-185/ulrich-rieke/raku/ch-1.raku b/challenge-185/ulrich-rieke/raku/ch-1.raku new file mode 100644 index 0000000000..c84b294a32 --- /dev/null +++ b/challenge-185/ulrich-rieke/raku/ch-1.raku @@ -0,0 +1,15 @@ +use v6 ; + +say "Please enter a MAC address in the form hhhh.hhhh.hhhh!" ; +my $line = $*IN.get ; +while ( $line !~~ /^(\w **4 '.') ** 2 \w ** 4 $/ ) { + say "Enter a Mac address in the form hhhh.hhhh.hhhh!" ; + $line = $*IN.get ; +} +my @parts = split( /'.'/ , $line ) ; +my @chunks ; +for @parts -> $part { + @chunks.push( $part.substr( 0 , 2 )) ; + @chunks.push( $part.substr( 2 , 2 )) ; +} +say @chunks.join( ':' ) ; diff --git a/challenge-185/ulrich-rieke/raku/ch-2.raku b/challenge-185/ulrich-rieke/raku/ch-2.raku new file mode 100644 index 0000000000..d7aad90770 --- /dev/null +++ b/challenge-185/ulrich-rieke/raku/ch-2.raku @@ -0,0 +1,23 @@ +use v6 ; + +sub mySubstitution( Str $word is copy ) { + my $count = 0 ; + my $pos = 0 ; + while ( $count < 4 ) { + if ( $word.substr( $pos , 1 ) ~~ /\w/ ) { + $word.substr-rw( $pos , 1 ) = "x" ; + $count++ ; + $pos++ ; + } + else { + $pos++ ; + } + } + return $word ; +} + +say "Enter some strings, separated by blanks!" ; +my $line = $*IN.get ; +my @words = $line.split( /\s/ ) ; +my @transformed = @words.map( { mySubstitution( $_ ) } ) ; +say @transformed.join( ',' ) ; diff --git a/challenge-185/ulrich-rieke/rust/ch-1.rs b/challenge-185/ulrich-rieke/rust/ch-1.rs new file mode 100644 index 0000000000..a033022a47 --- /dev/null +++ b/challenge-185/ulrich-rieke/rust/ch-1.rs @@ -0,0 +1,28 @@ +use std::io ; + +fn main() { + println!("Please enter an MAC address in the form hhhh.hhhh.hhhh!") ; + let mut input : String = String::new( ) ; + io::stdin( ).read_line( &mut input ).unwrap( ) ; + let mut entered_line : &str = &*input ; + entered_line = entered_line.trim( ) ; + let mut from : usize = 0 ; + let mut to : usize = 1 ; + let mut chunks : Vec<&str> = Vec::new( ) ; + while to < input.len( ) { + chunks.push( &entered_line[from..=to] ) ; + from += 2 ; + to += 2 ; + match entered_line.chars( ).nth( from ) { + Some ( '.' ) => { from += 1 ; to += 1 ; } , + None => {} , + _ => {} , + } + } + let mut outputstring : String = String::new( ) ; + for s in chunks { + outputstring.push_str( &s.to_string( ) ) ; + outputstring.push( ':' ) ; + } + println!("{}" , &outputstring[0..outputstring.len( ) - 1] ) ; +} diff --git a/challenge-185/ulrich-rieke/rust/ch-2.rs b/challenge-185/ulrich-rieke/rust/ch-2.rs new file mode 100644 index 0000000000..377baa891b --- /dev/null +++ b/challenge-185/ulrich-rieke/rust/ch-2.rs @@ -0,0 +1,17 @@ +use std::io ; + +fn main() { + println!("Please enter some strings, separated by a blank!" ) ; + let mut input : String = String::new( ) ; + io::stdin( ).read_line( &mut input ).unwrap( ) ; + let entered_line = &*input ; + let mut outputwords : Vec<&str> = Vec::new( ) ; + let mut iter = entered_line.split_whitespace( ) ; + while let Some( word ) = iter.next( ) { + outputwords.push( word ) ; + } + for s in outputwords { + print!("{} " , s.replacen( char::is_alphanumeric , "x" , 4 )) ; + } + println!() ; +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index bf559d7775..c6c672a2cd 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,4 +1,138 @@ { + "chart" : { + "type" : "column" + }, + "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 + }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, + "subtitle" : { + "text" : "[Champions: 19] Last updated at 2022-10-04 19:16:12 GMT" + }, + "legend" : { + "enabled" : 0 + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "title" : { + "text" : "The Weekly Challenge - 185" + }, + "series" : [ + { + "data" : [ + { + "y" : 4, + "name" : "Andinus", + "drilldown" : "Andinus" + }, + { + "y" : 2, + "name" : "Branislav Zahradnik", + "drilldown" : "Branislav Zahradnik" + }, + { + "drilldown" : "Dave Cross", + "name" : "Dave Cross", + "y" : 2 + }, + { + "name" : "E. Choroba", + "y" : 2, + "drilldown" : "E. Choroba" + }, + { + "name" : "Humberto Massa", + "y" : 2, + "drilldown" : "Humberto Massa" + }, + { + "drilldown" : "Jaldhar H. Vyas", + "y" : 5, + "name" : "Jaldhar H. Vyas" + }, + { + "y" : 3, + "name" : "James Smith", + "drilldown" : "James Smith" + }, + { + "y" : 2, + "name" : "Julien Fiegehenn", + "drilldown" : "Julien Fiegehenn" + }, + { + "name" : "Kueppo Wesley", + "y" : 1, + "drilldown" : "Kueppo Wesley" + }, + { + "drilldown" : "Luca Ferrari", + "name" : "Luca Ferrari", + "y" : 8 + }, + { + "y" : 2, + "name" : "Mark Anderson", + "drilldown" : "Mark Anderson" + }, + { + "name" : "Matthew Neleigh", + "y" : 2, + "drilldown" : "Matthew Neleigh" + }, + { + "drilldown" : "Mohammad S Anwar", + "name" : "Mohammad S Anwar", + "y" : 2 + }, + { + "drilldown" : "Niels van Dijke", + "name" : "Niels van Dijke", + "y" : 2 + }, + { + "drilldown" : "Peter Campbell Smith", + "y" : 3, + "name" : "Peter Campbell Smith" + }, + { + "drilldown" : "Robert DiCicco", + "name" : "Robert DiCicco", + "y" : 3 + }, + { + "y" : 5, + "name" : "Stephen G. Lynn", + "drilldown" : "Stephen G. Lynn" + }, + { + "name" : "Ulrich Rieke", + "y" : 4, + "drilldown" : "Ulrich Rieke" + }, + { + "drilldown" : "W. Luis Mochan", + "y" : 3, + "name" : "W. Luis Mochan" + } + ], + "colorByPoint" : 1, + "name" : "The Weekly Challenge - 185" + } + ], "drilldown" : { "series" : [ { @@ -27,33 +161,33 @@ }, { "name" : "Dave Cross", - "id" : "Dave Cross", "data" : [ [ "Perl", 2 ] - ] + ], + "id" : "Dave Cross" }, { - "name" : "E. Choroba", "data" : [ [ "Perl", 2 ] ], - "id" : "E. Choroba" + "id" : "E. Choroba", + "name" : "E. Choroba" }, { - "name" : "Humberto Massa", "id" : "Humberto Massa", "data" : [ [ "Raku", 2 ] - ] + ], + "name" : "Humberto Massa" }, { "id" : "Jaldhar H. Vyas", @@ -89,25 +223,26 @@ }, { "name" : "Julien Fiegehenn", + "id" : "Julien Fiegehenn", "data" : [ [ "Perl", 2 ] - ], - "id" : "Julien Fiegehenn" + ] }, { + "name" : "Kueppo Wesley", "data" : [ [ "Perl", 1 ] ], - "id" : "Kueppo Wesley", - "name" : "Kueppo Wesley" + "id" : "Kueppo Wesley" }, { + "id" : "Luca Ferrari", "data" : [ [ "Raku", @@ -118,7 +253,6 @@ 6 ] ], - "id" : "Luca Ferrari", "name" : "Luca Ferrari" }, { @@ -132,36 +266,37 @@ ] }, { + "name" : "Matthew Neleigh", "data" : [ [ "Perl", 2 ] ], - "id" : "Matthew Neleigh", - "name" : "Matthew Neleigh" + "id" : "Matthew Neleigh" }, { + "name" : "Mohammad S Anwar", "id" : "Mohammad S Anwar", "data" : [ [ "Perl", 2 ] - ], - "name" : "Mohammad S Anwar" + ] }, { - "id" : "Niels van Dijke", + "name" : "Niels van Dijke", "data" : [ [ "Perl", 2 ] ], - "name" : "Niels van Dijke" + "id" : "Niels van Dijke" }, { + "name" : "Peter Campbell Smith", "id" : "Peter Campbell Smith", "data" : [ [ @@ -172,11 +307,9 @@ "Blog", 1 ] - ], - "name" : "Peter Campbell Smith" + ] }, { - "name" : "Robert DiCicco", "id" : "Robert DiCicco", "data" : [ [ @@ -187,9 +320,12 @@ "Raku", 1 ] - ] + ], + "name" : "Robert DiCicco" }, { + "name" : "Stephen G. Lynn", + "id" : "Stephen G. Lynn", "data" : [ [ "Perl", @@ -203,9 +339,21 @@ "Blog", 1 ] - ], - "id" : "Stephen G. Lynn", - "name" : "Stephen G. Lynn" + ] + }, + { + "name" : "Ulrich Rieke", + "id" : "Ulrich Rieke", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ] }, { "id" : "W. Luis Mochan", @@ -225,134 +373,5 @@ }, "xAxis" : { "type" : "category" - }, - "legend" : { - "enabled" : 0 - }, - "title" : { - "text" : "The Weekly Challenge - 185" - }, - "chart" : { - "type" : "column" - }, - "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 - }, - "plotOptions" : { - "series" : { - "borderWidth" : 0, - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - } - } - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "series" : [ - { - "data" : [ - { - "name" : "Andinus", - "y" : 4, - "drilldown" : "Andinus" - }, - { - "name" : "Branislav Zahradnik", - "y" : 2, - "drilldown" : "Branislav Zahradnik" - }, - { - "name" : "Dave Cross", - "y" : 2, - "drilldown" : "Dave Cross" - }, - { - "y" : 2, - "drilldown" : "E. Choroba", - "name" : "E. Choroba" - }, - { - "y" : 2, - "drilldown" : "Humberto Massa", - "name" : "Humberto Massa" - }, - { - "y" : 5, - "drilldown" : "Jaldhar H. Vyas", - "name" : "Jaldhar H. Vyas" - }, - { - "drilldown" : "James Smith", - "y" : 3, - "name" : "James Smith" - }, - { - "name" : "Julien Fiegehenn", - "y" : 2, - "drilldown" : "Julien Fiegehenn" - }, - { - "name" : "Kueppo Wesley", - "y" : 1, - "drilldown" : "Kueppo Wesley" - }, - { - "drilldown" : "Luca Ferrari", - "y" : 8, - "name" : "Luca Ferrari" - }, - { - "name" : "Mark Anderson", - "y" : 2, - "drilldown" : "Mark Anderson" - }, - { - "drilldown" : "Matthew Neleigh", - "y" : 2, - "name" : "Matthew Neleigh" - }, - { - "y" : 2, - "drilldown" : "Mohammad S Anwar", - "name" : "Mohammad S Anwar" - }, - { - "name" : "Niels van Dijke", - "drilldown" : "Niels van Dijke", - "y" : 2 - }, - { - "y" : 3, - "drilldown" : "Peter Campbell Smith", - "name" : "Peter Campbell Smith" - }, - { - "drilldown" : "Robert DiCicco", - "y" : 3, - "name" : "Robert DiCicco" - }, - { - "y" : 5, - "drilldown" : "Stephen G. Lynn", - "name" : "Stephen G. Lynn" - }, - { - "name" : "W. Luis Mochan", - "y" : 3, - "drilldown" : "W. Luis Mochan" - } - ], - "colorByPoint" : 1, - "name" : "The Weekly Challenge - 185" - } - ], - "subtitle" : { - "text" : "[Champions: 18] Last updated at 2022-10-04 18:32:28 GMT" } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 06b8b34ebf..f6a98d1ca6 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,15 +1,6 @@ { - "xAxis" : { - "type" : "category", - "labels" : { - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - } - } - }, - "title" : { - "text" : "The Weekly Challenge Contributions [2019 - 2022]" + "subtitle" : { + "text" : "Last updated at 2022-10-04 19:16:12 GMT" }, "legend" : { "enabled" : "false" @@ -20,21 +11,26 @@ "text" : null } }, + "chart" : { + "type" : "column" + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "xAxis" : { + "labels" : { + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + } + }, + "type" : "category" + }, + "title" : { + "text" : "The Weekly Challenge Contributions [2019 - 2022]" + }, "series" : [ { - "dataLabels" : { - "color" : "#FFFFFF", - "format" : "{point.y:.0f}", - "align" : "right", - "enabled" : "true", - "y" : 10, - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - }, - "rotation" : -90 - }, - "name" : "Contributions", "data" : [ [ "Blog", @@ -42,22 +38,26 @@ ], [ "Perl", - 8998 + 9000 ], [ "Raku", - 5375 + 5377 ] - ] + ], + "dataLabels" : { + "rotation" : -90, + "format" : "{point.y:.0f}", + "color" : "#FFFFFF", + "y" : 10, + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + }, + "align" : "right", + "enabled" : "true" + }, + "name" : "Contributions" } - ], - "subtitle" : { - "text" : "Last updated at 2022-10-04 18:32:28 GMT" - }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - }, - "chart" : { - "type" : "column" - } + ] } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 965f09364a..e4968ccbf4 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,4 +1,35 @@ { + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "legend" : { + "enabled" : "false" + }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + } + } + }, + "subtitle" : { + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2022-10-04 19:16:12 GMT" + }, + "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" + }, + "chart" : { + "type" : "column" + }, + "xAxis" : { + "type" : "category" + }, "drilldown" : { "series" : [ { @@ -21,6 +52,7 @@ }, { "name" : "002", + "id" : "002", "data" : [ [ "Perl", @@ -34,10 +66,10 @@ "Blog", 10 ] - ], - "id" : "002" + ] }, { + "name" : "003", "id" : "003", "data" : [ [ @@ -52,8 +84,7 @@ "Blog", 9 ] - ], - "name" : "003" + ] }, { "id" : "004", @@ -74,7 +105,7 @@ "name" : "004" }, { - "name" : "005", + "id" : "005", "data" : [ [ "Perl", @@ -89,9 +120,10 @@ 12 ] ], - "id" : "005" + "name" : "005" }, { + "name" : "006", "data" : [ [ "Perl", @@ -106,12 +138,9 @@ 7 ] ], - "id" : "006", - "name" : "006" + "id" : "006" }, { - "name" : "007", - "id" : "007", "data" : [ [ "Perl", @@ -125,7 +154,9 @@ "Blog", 10 ] - ] + ], + "id" : "007", + "name" : "007" }, { "name" : "008", @@ -164,6 +195,7 @@ "name" : "009" }, { + "name" : "010", "data" : [ [ "Perl", @@ -178,11 +210,9 @@ 11 ] ], - "id" : "010", - "name" : "010" + "id" : "010" }, { - "id" : "011", "data" : [ [ "Perl", @@ -197,10 +227,11 @@ 10 ] ], + "id" : "011", "name" : "011" }, { - "name" : "012", + "id" : "012", "data" : [ [ "Perl", @@ -215,10 +246,9 @@ 11 ] ], - "id" : "012" + "name" : "012" |
