diff options
32 files changed, 2908 insertions, 2572 deletions
diff --git a/challenge-280/ulrich-rieke/cpp/ch-1.cpp b/challenge-280/ulrich-rieke/cpp/ch-1.cpp new file mode 100755 index 0000000000..fdcedc541d --- /dev/null +++ b/challenge-280/ulrich-rieke/cpp/ch-1.cpp @@ -0,0 +1,21 @@ +#include <iostream>
+#include <string>
+#include <map>
+
+int main( ) {
+ std::cout << "Enter a word with lowercase English letters only!\n" ;
+ std::string word ;
+ std::cin >> word ;
+ std::map<char , int> frequencies ;
+ char result {' '} ;
+ for ( int i = 0 ; i < word.length( ) ; i++ ) {
+ char c = word[i] ;
+ frequencies[c]++ ;
+ if (frequencies.find( c )->second == 2) {
+ result = c ;
+ break ;
+ }
+ }
+ std::cout << result << '\n' ;
+ return 0 ;
+}
diff --git a/challenge-280/ulrich-rieke/cpp/ch-2.cpp b/challenge-280/ulrich-rieke/cpp/ch-2.cpp new file mode 100755 index 0000000000..d228e4ce60 --- /dev/null +++ b/challenge-280/ulrich-rieke/cpp/ch-2.cpp @@ -0,0 +1,36 @@ +#include <iostream>
+#include <string>
+#include <algorithm>
+
+int main( ) {
+ std::cout << "Enter a string with some vertical bars!\n" ;
+ std::string line ;
+ std::cin >> line ;
+ if ( std::count( line.begin( ) , line.end( ) , '|' ) <= 1 ) {
+ std::cout << std::count( line.begin( ) , line.end( ) , '*' ) <<
+ '\n' ;
+ }
+ else {
+ bool barSeen = false ;
+ std::string filtered ;
+ for ( int i = 0 ; i < line.length( ) ; i++ ) {
+ char c = line[i] ;
+ if ( c != '|' )
+ filtered.append( 1, c ) ;
+ else {
+ if ( barSeen ) {
+ auto pos = filtered.find( '|' ) ;
+ filtered = filtered.substr( 0 , pos ) ;
+ barSeen = false ;
+ }
+ else {
+ filtered.append( 1 , '|' ) ;
+ barSeen = true ;
+ }
+ }
+ }
+ std::cout << std::count( filtered.begin( ) , filtered.end( ) ,
+ '*' ) << '\n' ;
+ }
+ return 0 ;
+}
diff --git a/challenge-280/ulrich-rieke/haskell/ch-1.hs b/challenge-280/ulrich-rieke/haskell/ch-1.hs new file mode 100755 index 0000000000..6c48b547ee --- /dev/null +++ b/challenge-280/ulrich-rieke/haskell/ch-1.hs @@ -0,0 +1,19 @@ +module Challenge280
+ where
+import qualified Data.Set as S
+import Data.List ( findIndices , sortOn )
+
+solution :: String -> Char
+solution s = if any ( (>= 2) . length . snd ) indices then fst $ head $
+ sortOn ( last . snd ) $ filter ( (> 1 ) . length . snd ) indices else ' '
+ where
+ indices = map (\c -> (c , findIndices (== c ) s ) ) $ S.toList $
+ S.fromList s
+
+main :: IO ( )
+main = do
+ putStrLn "Enter a word of lowercase letters only!"
+ line <- getLine
+ print $ solution line
+
+
diff --git a/challenge-280/ulrich-rieke/haskell/ch-2.hs b/challenge-280/ulrich-rieke/haskell/ch-2.hs new file mode 100755 index 0000000000..7daca1afcb --- /dev/null +++ b/challenge-280/ulrich-rieke/haskell/ch-2.hs @@ -0,0 +1,26 @@ +module Challenge280_2
+ where
+import Data.List ( findIndices )
+import Data.List.Split ( chunksOf )
+
+findForbiddenIndices :: String -> [Int]
+findForbiddenIndices s = concat $ map (\subli -> if length subli == 2 then
+ [head subli..last subli] else [] ) $ chunksOf 2 indices
+ where
+ indices = findIndices ( == '|' ) s
+
+solution :: String -> Int
+solution s = if (length $ findIndices ( == '|' ) s ) <= 1 then length $
+ findIndices ( == '*' ) s else length $ filter (\p -> notElem ( fst p )
+ forbidden && ( snd p == '*' ) ) $ zip [0 , 1 .. ] s
+ where
+ forbidden = findForbiddenIndices s
+
+main :: IO ( )
+main = do
+ putStrLn "Enter a string with some vertical bars!"
+ line <- getLine
+ print $ solution line
+
+
+
diff --git a/challenge-280/ulrich-rieke/perl/ch-1.pl b/challenge-280/ulrich-rieke/perl/ch-1.pl new file mode 100755 index 0000000000..b36a4d0fe3 --- /dev/null +++ b/challenge-280/ulrich-rieke/perl/ch-1.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+
+say "Please enter a word consisting of lowercase English letters only!" ;
+my $word = <STDIN> ;
+chomp $word ;
+my %frequencies ;
+my $result = ' ' ;
+#iterate through the letters of the word
+#once you encounter one with 2 occurrences , end loop and output it
+for my $letter( split( // , $word ) ) {
+ $frequencies{$letter}++ ;
+ if ( $frequencies{$letter} == 2 ) {
+ $result = $letter ;
+ last ;
+ }
+}
+say $result ;
diff --git a/challenge-280/ulrich-rieke/perl/ch-2.pl b/challenge-280/ulrich-rieke/perl/ch-2.pl new file mode 100755 index 0000000000..3155569f9d --- /dev/null +++ b/challenge-280/ulrich-rieke/perl/ch-2.pl @@ -0,0 +1,40 @@ +#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+
+sub count {
+ my $haystack = shift ;
+ my $needle = shift ;
+ return scalar( grep { $_ eq $needle } split( // , $haystack ) ) ;
+}
+
+say "Enter a string with some bars!" ;
+my $line = <STDIN> ;
+chomp $line ;
+my $barcount = count( $line , '|' ) ;
+if ( $barcount <= 1 ) {
+ my $result = count( $line , '*' ) ;
+ say $result ;
+}
+else {
+ my $barFound = 0 ;
+ my $filtered ;
+ for my $c ( split( // , $line )) {
+ if ( $c ne '|' ) {
+ $filtered .= $c ;
+ }
+ else {
+ if ( $barFound ) {
+ my $pos = index( $filtered , '|' ) ;
+ $filtered = substr( $filtered , 0 , $pos ) ;
+ $barFound = 0 ;
+ }
+ else {
+ $filtered .= '|' ;
+ $barFound = 1 ;
+ }
+ }
+ }
+ say count( $filtered , '*' ) ;
+}
diff --git a/challenge-280/ulrich-rieke/raku/ch-1.raku b/challenge-280/ulrich-rieke/raku/ch-1.raku new file mode 100755 index 0000000000..f89b5540e9 --- /dev/null +++ b/challenge-280/ulrich-rieke/raku/ch-1.raku @@ -0,0 +1,14 @@ +use v6 ;
+
+say "Enter a word consisting of lowercase English letters only!" ;
+my $word = $*IN.get ;
+my %frequencies ;
+my $result = ' ' ;
+for $word.comb -> $letter {
+ %frequencies{$letter}++ ;
+ if (%frequencies{$letter} == 2) {
+ $result = $letter ;
+ last ;
+ }
+}
+say $result ;
diff --git a/challenge-280/ulrich-rieke/raku/ch-2.raku b/challenge-280/ulrich-rieke/raku/ch-2.raku new file mode 100755 index 0000000000..3850d644d6 --- /dev/null +++ b/challenge-280/ulrich-rieke/raku/ch-2.raku @@ -0,0 +1,41 @@ +use v6 ;
+
+sub count( $word , $char ) {
+ my $total = 0 ;
+ for (0..$word.chars - 1) -> $i {
+ if ( $word.substr( $i , 1 ) eq $char ) {
+ $total++ ;
+ }
+ }
+ return $total ;
+}
+
+say "Enter a string with some bars!" ;
+my $line = $*IN.get ;
+if ( count( $line , "|" ) <= 1 ) {
+ my $result = count( $line , "*" ) ;
+ say $result ;
+}
+else {
+ my $barFound = False ;
+ my $filtered ; #copy with only the characters we are looking for
+ for $line.comb -> $c {
+ if ( $c ne "|" ) {
+ $filtered ~= $c ;
+ }
+ else {
+#if we haven't found a bar yet we add a new bar
+#otherwise we remove everything from the last bar on
+ if ( $barFound ) {
+ my $pos = $filtered.index( "|" ) ;
+ $filtered .= substr( 0 , $pos ) ;
+ $barFound = False ;
+ }
+ else {
+ $filtered ~= "|" ;
+ $barFound = True ;
+ }
+ }
+ }
+ say count( $filtered , "*" ) ;
+}
diff --git a/challenge-280/ulrich-rieke/rust/ch-1.rs b/challenge-280/ulrich-rieke/rust/ch-1.rs new file mode 100755 index 0000000000..39329e55d4 --- /dev/null +++ b/challenge-280/ulrich-rieke/rust/ch-1.rs @@ -0,0 +1,20 @@ +use std::io ; +use std::collections::HashMap ; + +fn main() { + println!("Enter a word with English lowercase letters only!"); + let mut inline : String = String::new( ) ; + io::stdin().read_line( &mut inline ).unwrap( ) ; + let entered_line : &str = inline.as_str( ).trim( ) ; + let mut frequencies = HashMap::new( ) ; + let mut result : char = ' ' ; + for c in entered_line.chars( ) { + frequencies.entry(c).and_modify( |counter| *counter += 1 ). + or_insert( 1 ) ; + if *frequencies.get( &c ).unwrap( ) == 2 { + result = c ; + break ; + } + } + println!("{}" , result ) ; +} diff --git a/challenge-280/ulrich-rieke/rust/ch-2.rs b/challenge-280/ulrich-rieke/rust/ch-2.rs new file mode 100755 index 0000000000..da2787cedd --- /dev/null +++ b/challenge-280/ulrich-rieke/rust/ch-2.rs @@ -0,0 +1,42 @@ +use std::io ; + +fn main() { + println!("Enter a string with vertical bars!"); + let mut inline : String = String::new( ) ; + io::stdin( ).read_line( &mut inline ).unwrap( ) ; + let entered_line : &str = inline.as_str( ).trim( ) ; + //anything with up to one bar can be directly evaluated + if entered_line.chars( ).filter( | &c | c == '|' ).count( ) <= 1 { + println!("{}" , entered_line.chars( ).filter( | &c | c == '*' ). + count( ) ) ; + } + //otherwise, we assume we have not seen a bar yet + //if this is true, we keep adding new chars that are not '|' + //if it is a bar then we would delete everything from the last bar + //if we have already seen a bar, otherwise we add the bar + else { + let mut bar_seen : bool = false ; + let mut for_analysis : String = String::new( ) ; + for c in entered_line.chars( ) { + if c == '|' { + if bar_seen { + let pos = for_analysis.find( '|' ).unwrap( ) ; + let first_part = &for_analysis[..pos] ; + for_analysis = first_part.into( ) ; + bar_seen = false ; + + } + else { + bar_seen = true ; + for_analysis.push( '|' ) ; + } + } + else { + for_analysis.push( c ) ; + } + } + let result = &for_analysis[..] ; + println!("{}" , result.chars( ).filter( | &c | c == '*' ). + count( ) ) ; + } +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 1a77b7f23d..877d5ca6a0 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,63 +1,171 @@ { + "title" : { + "text" : "The Weekly Challenge - 280" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "xAxis" : { + "type" : "category" + }, "subtitle" : { - "text" : "[Champions: 11] Last updated at 2024-07-29 22:49:06 GMT" + "text" : "[Champions: 14] Last updated at 2024-07-30 11:39:46 GMT" + }, + "legend" : { + "enabled" : 0 }, "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 + "followPointer" : 1, + "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>" + }, + "series" : [ + { + "data" : [ + { + "drilldown" : "Alexander Karelas", + "y" : 1, + "name" : "Alexander Karelas" + }, + { + "drilldown" : "Dave Jacoby", + "name" : "Dave Jacoby", + "y" : 3 + }, + { + "drilldown" : "David Ferrone", + "y" : 2, + "name" : "David Ferrone" + }, + { + "drilldown" : "E. Choroba", + "name" : "E. Choroba", + "y" : 2 + }, + { + "drilldown" : "Feng Chang", + "name" : "Feng Chang", + "y" : 2 + }, + { + "drilldown" : "Laurent Rosenfeld", + "name" : "Laurent Rosenfeld", + "y" : 3 + }, + { + "drilldown" : "Luca Ferrari", + "name" : "Luca Ferrari", + "y" : 12 + }, + { + "drilldown" : "Mark Anderson", + "name" : "Mark Anderson", + "y" : 2 + }, + { + "drilldown" : "Matthew Neleigh", + "y" : 2, + "name" : "Matthew Neleigh" + }, + { + "y" : 2, + "drilldown" : "Peter Meszaros", + "name" : "Peter Meszaros" + }, + { + "name" : "Robbie Hatley", + "drilldown" : "Robbie Hatley", + "y" : 3 + }, + { + "drilldown" : "Thomas Kohler", + "name" : "Thomas Kohler", + "y" : 4 + }, + { + "y" : 4, + "drilldown" : "Ulrich Rieke", + "name" : "Ulrich Rieke" + }, + { + "y" : 3, + "drilldown" : "W. Luis Mochan", + "name" : "W. Luis Mochan" + } + ], + "colorByPoint" : 1, + "name" : "The Weekly Challenge - 280" + } + ], + "chart" : { + "type" : "column" + }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } }, "drilldown" : { "series" : [ { + "name" : "Alexander Karelas", + "id" : "Alexander Karelas", "data" : [ [ "Perl", 1 ] - ], - "name" : "Alexander Karelas", - "id" : "Alexander Karelas" + ] }, { - "name" : "Dave Jacoby", "id" : "Dave Jacoby", "data" : [ [ "Perl", 2 + ], + [ + "Blog", + 1 ] - ] + ], + "name" : "Dave Jacoby" }, { + "name" : "David Ferrone", + "id" : "David Ferrone", "data" : [ [ "Perl", 2 ] - ], - "name" : "David Ferrone", - "id" : "David Ferrone" + ] }, { + "name" : "E. Choroba", + "id" : "E. Choroba", "data" : [ [ "Perl", 2 ] - ], - "name" : "E. Choroba", - "id" : "E. Choroba" + ] }, { "id" : "Feng Chang", - "name" : "Feng Chang", "data" : [ [ "Raku", 2 ] - ] + ], + "name" : "Feng Chang" }, { "data" : [ @@ -74,10 +182,11 @@ 1 ] ], - "name" : "Laurent Rosenfeld", - "id" : "Laurent Rosenfeld" + "id" : "Laurent Rosenfeld", + "name" : "Laurent Rosenfeld" }, { + "id" : "Luca Ferrari", "data" : [ [ "Raku", @@ -88,7 +197,6 @@ 10 ] ], - "id" : "Luca Ferrari", "name" : "Luca Ferrari" }, { @@ -102,16 +210,42 @@ "name" : "Mark Anderson" }, { + "name" : "Matthew Neleigh", + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Matthew Neleigh" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], "id" : "Peter Meszaros", - "name" : "Peter Meszaros", + "name" : "Peter Meszaros" + }, + { + "name" : "Robbie Hatley", + "id" : "Robbie Hatley", "data" : [ [ "Perl", 2 + ], + [ + "Blog", + 1 ] ] }, { + "name" : "Thomas Kohler", + "id" : "Thomas Kohler", "data" : [ [ "Perl", @@ -121,13 +255,24 @@ "Blog", 2 ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] ], - "id" : "Thomas Kohler", - "name" : "Thomas Kohler" + "id" : "Ulrich Rieke", + "name" : "Ulrich Rieke" }, { "name" : "W. Luis Mochan", - "id" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -137,97 +282,9 @@ "Blog", 1 ] - ] + ], + "id" : "W. Luis Mochan" } ] - }, - "chart" : { - "type" : "column" - }, - "title" : { - "text" : "The Weekly Challenge - 280" - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "xAxis" : { - "type" : "category" - }, - "series" : [ - { - "name" : "The Weekly Challenge - 280", - "data" : [ - { - "name" : "Alexander Karelas", - "y" : 1, - "drilldown" : "Alexander Karelas" - }, - { - "drilldown" : "Dave Jacoby", - "y" : 2, - "name" : "Dave Jacoby" - }, - { - "drilldown" : "David Ferrone", - "y" : 2, - "name" : "David Ferrone" - }, - { - "y" : 2, - "name" : "E. Choroba", - "drilldown" : "E. Choroba" - }, - { - "y" : 2, - "name" : "Feng Chang", - "drilldown" : "Feng Chang" - }, - { - "name" : "Laurent Rosenfeld", - "y" : 3, - "drilldown" : "Laurent Rosenfeld" - }, - { - "name" : "Luca Ferrari", - "y" : 12, - "drilldown" : "Luca Ferrari" - }, - { - "name" : "Mark Anderson", - "y" : 2, - "drilldown" : "Mark Anderson" - }, - { - "name" : "Peter Meszaros", - "y" : 2, - "drilldown" : "Peter Meszaros" - }, - { - "drilldown" : "Thomas Kohler", - "name" : "Thomas Kohler", - "y" : 4 - }, - { - "drilldown" : "W. Luis Mochan", - "name" : "W. Luis Mochan", - "y" : 3 - } - ], - "colorByPoint" : 1 - } - ], - "plotOptions" : { - "series" : { - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - }, - "borderWidth" : 0 - } - }, - "legend" : { - "enabled" : 0 } } diff --git a/stats/pwc-language-breakdown-2019.json b/stats/pwc-language-breakdown-2019.json index f7d5d8e018..d70c862a3b 100644 --- a/stats/pwc-language-breakdown-2019.json +++ b/stats/pwc-language-breakdown-2019.json @@ -1,229 +1,4 @@ { - "legend" : { - "enabled" : "false" - }, - "plotOptions" : { - "series" : { - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 - } - }, - "series" : [ - { - "data" : [ - { - "drilldown" : "001", - "name" : "#001", - "y" : 165 - }, - { - "y" : 133, - "name" : "#002", - "drilldown" : "002" - }, - { - "name" : "#003", - "y" : 91, - "drilldown" : "003" - }, - { - "drilldown" : "004", - "name" : "#004", - "y" : 106 - }, - { - "drilldown" : "005", - "name" : "#005", - "y" : 82 - }, - { - "name" : "#006", - "y" : 63, - "drilldown" : "006" - }, - { - "name" : "#007", - "y" : 71, - "drilldown" : "007" - }, - { - "drilldown" : "008", - "name" : "#008", - "y" : 82 - }, - { - "drilldown" : "009", - "y" : 79, - "name" : "#009" - }, - { - "y" : 69, - "name" : "#010", - "drilldown" : "010" - }, - { - "drilldown" : "011", - "y" : 86, - "name" : "#011" - }, - { - "y" : 90, - "name" : "#012", - "drilldown" : "012" - }, - { - "y" : 85, - "name" : "#013", - "drilldown" : "013" - }, - { - "drilldown" : "014", - "name" : "#014", - "y" : 98 - }, - { - "drilldown" : "015", - "y" : 95, - "name" : "#015" - }, - { - "name" : "#016", - "y" : 75, - "drilldown" : "016" - }, - { - "y" : 83, - "name" : "#017", - "drilldown" : "017" - }, - { - "y" : 82, - "name" : "#018", - "drilldown" : "018" - }, - { - "name" : "#019", - "y" : 101, - "drilldown" : "019" - }, - { - "drilldown" : "020", - "name" : "#020", - "y" : 100 - }, - { - "drilldown" : "021", - "y" : 72, - "name" : "#021" - }, - { - "drilldown" : "022", - "name" : "#022", - "y" : 72 - }, - { - "drilldown" : "023", - "name" : "#023", - "y" : 88 - }, - { - "drilldown" : "024", - "y" : 77, - "name" : "#024" - }, - { - "y" : 62, - "name" : "#025", - "drilldown" : "025" - }, - { - "y" : 75, - "name" : "#026", - "drilldown" : "026" - }, - { - "drilldown" : "027", - "name" : "#027", - "y" : 64 - }, - { - "y" : 82, - "name" : "#028", - "drilldown" : "028" - }, - { - "name" : "#029", - "y" : 83, - "drilldown" : "029" - }, - { - "drilldown" : "030", - "y" : 120, - "name" : "#030" - }, - { - "y" : 93, - "name" : "#031", - "drilldown" : "031" - }, - { - "drilldown" : "032", - "name" : "#032", - "y" : 97 - }, - { - "drilldown" : "033", - "name" : "#033", - "y" : 113 - }, - { - "name" : "#034", - "y" : 70, - "drilldown" : "034" - }, - { - "name" : "#035", - "y" : 68, - "drilldown" : "035" - }, - { - "y" : 70, - "name" : "#036", - "drilldown" : "036" - }, - { - "drilldown" : "037", - "name" : "#037", - "y" : 70 - }, |
