diff options
37 files changed, 1052 insertions, 442 deletions
diff --git a/challenge-330/eric-cheung/python/ch-1.py b/challenge-330/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..7cb84e86b6 --- /dev/null +++ b/challenge-330/eric-cheung/python/ch-1.py @@ -0,0 +1,16 @@ +
+## strInput = "cab12" ## Example 1
+## strInput = "xy99" ## Example 2
+strInput = "pa1erl" ## Example 3
+
+arrInput = list(strInput)
+
+while len([charLoop for charLoop in arrInput if charLoop.isdigit()]) > 0:
+ nFirstNumDigit = [nIndx for nIndx, charLoop in enumerate(arrInput) if charLoop.isdigit()][0]
+ if nFirstNumDigit == 0:
+ break
+
+ del arrInput[nFirstNumDigit]
+ del arrInput[nFirstNumDigit - 1]
+
+print ("".join(arrInput))
diff --git a/challenge-330/eric-cheung/python/ch-2.py b/challenge-330/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..1ccef2a8d9 --- /dev/null +++ b/challenge-330/eric-cheung/python/ch-2.py @@ -0,0 +1,22 @@ +
+## strInput = "PERL IS gREAT" ## Example 1
+## strInput = "THE weekly challenge" ## Example 2
+strInput = "YoU ARE A stAR" ## Example 3
+
+## ==== METHOD 1 ====
+## arrOutput = []
+
+## for strLoop in strInput.split(" "):
+ ## if len(strLoop) < 3:
+ ## arrOutput.append(strLoop.lower())
+ ## else:
+ ## ## arrOutput.append(strLoop[0].upper() + strLoop[1:].lower())
+ ## arrOutput.append(strLoop.title())
+## ==== METHOD 1 ====
+
+## ==== METHOD 2 ====
+## arrOutput = [strLoop.lower() if len(strLoop) < 3 else strLoop[0].upper() + strLoop[1:].lower() for strLoop in strInput.split(" ")]
+arrOutput = [strLoop.lower() if len(strLoop) < 3 else strLoop.title() for strLoop in strInput.split(" ")]
+## ==== METHOD 2 ====
+
+print (" ".join(arrOutput))
diff --git a/challenge-330/ulrich-rieke/cpp/ch-1.cpp b/challenge-330/ulrich-rieke/cpp/ch-1.cpp new file mode 100755 index 0000000000..2a9d38ddba --- /dev/null +++ b/challenge-330/ulrich-rieke/cpp/ch-1.cpp @@ -0,0 +1,23 @@ +#include <string>
+#include <iostream>
+#include <regex>
+using namespace std::string_literals ;
+
+int main( ) {
+ std::cout << "Enter a string with lowercase English letters and digits only!\n" ;
+ std::string word ;
+ std::cin >> word ;
+ std::regex wanted { "\\D\\d" } ;
+ while ( std::regex_search( word , wanted )) {
+ word = std::regex_replace( word , wanted , "" ,
+ std::regex_constants::format_first_only) ;
+ }
+ if ( word.length( ) > 0 ) {
+ std::cout << word ;
+ }
+ else {
+ std::cout << "\"\"" ;
+ }
+ std::cout << '\n' ;
+ return 0 ;
+}
diff --git a/challenge-330/ulrich-rieke/cpp/ch-2.cpp b/challenge-330/ulrich-rieke/cpp/ch-2.cpp new file mode 100755 index 0000000000..615f6f45cb --- /dev/null +++ b/challenge-330/ulrich-rieke/cpp/ch-2.cpp @@ -0,0 +1,46 @@ +#include <string>
+#include <vector>
+#include <iostream>
+#include <sstream>
+#include <cctype>
+
+std::vector<std::string> split( const std::string & text , char delimiter ) {
+ std::vector<std::string> tokens ;
+ std::istringstream istr { text } ;
+ std::string word ;
+ while ( std::getline( istr , word , delimiter ) )
+ tokens.push_back( word ) ;
+ return tokens ;
+}
+
+int main( ) {
+ std::cout << "Enter a string with some words separated by space!\n" ;
+ std::string line ;
+ std::getline( std::cin , line ) ;
+ auto tokens { split( line , ' ' ) } ;
+ std::string result ;
+ for ( auto s : tokens ) {
+ if ( s.length( ) < 3 ) {
+ for ( auto c : s ) {
+ result.push_back( std::tolower( c ) ) ;
+ }
+ }
+ else {
+ for ( auto c : s ) {
+ if ( c == s[0] ) {
+ result.push_back( std::toupper( c ) ) ;
+ }
+ else {
+ result.push_back( std::tolower( c ) ) ;
+ }
+ }
+ }
+ result.push_back( ' ' ) ;
+ }
+ result.pop_back( ) ;
+ std::cout << result << '\n' ;
+ return 0 ;
+}
+
+
+
diff --git a/challenge-330/ulrich-rieke/haskell/ch-1.hs b/challenge-330/ulrich-rieke/haskell/ch-1.hs new file mode 100755 index 0000000000..907d3d0f4c --- /dev/null +++ b/challenge-330/ulrich-rieke/haskell/ch-1.hs @@ -0,0 +1,25 @@ +module Challenge330
+ where
+import Data.List.Split ( divvy )
+import Data.Char ( isLetter , isDigit )
+import Data.List ( findIndex )
+
+removePair :: String -> Int -> String
+removePair str at = take at str ++ drop ( at + 2 ) str
+
+condition :: String -> Bool
+condition str = (isLetter $ head str) && ( isDigit $ last str )
+
+solution :: String -> String
+solution str = until (\s -> not $ any condition $ divvy 2 1 s) step str
+ where
+ step :: String -> String
+ step someString = case findIndex condition $ divvy 2 1 someString of
+ Just pos -> removePair someString pos
+ Nothing -> someString
+
+main :: IO ( )
+main = do
+ putStrLn "Enter a word with lowercase English letters and digits only!"
+ word <- getLine
+ print $ solution word
diff --git a/challenge-330/ulrich-rieke/haskell/ch-2.hs b/challenge-330/ulrich-rieke/haskell/ch-2.hs new file mode 100755 index 0000000000..307d434570 --- /dev/null +++ b/challenge-330/ulrich-rieke/haskell/ch-2.hs @@ -0,0 +1,17 @@ +module Challenge330_2
+ where
+import Data.Char ( toUpper , toLower )
+import Data.List ( tail )
+
+convert :: String -> String
+convert str = if length str < 3 then map toLower str else [toUpper $ head
+ str] ++ ( map toLower $ tail str )
+
+solution :: String -> String
+solution = unwords . map convert . words
+
+main :: IO ( )
+main = do
+ putStrLn "Enter a sentence with words separated by space!"
+ line <- getLine
+ print $ solution line
diff --git a/challenge-330/ulrich-rieke/perl/ch-1.pl b/challenge-330/ulrich-rieke/perl/ch-1.pl new file mode 100755 index 0000000000..556dfdfcbf --- /dev/null +++ b/challenge-330/ulrich-rieke/perl/ch-1.pl @@ -0,0 +1,17 @@ +#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+
+say "Enter a word with lowercase English letters and digits only!" ;
+my $word = <STDIN> ;
+chomp $word ;
+while ( $word =~ /(\D\d)/ ) {
+ $word =~ s/$1// ;
+}
+if ( $word ) {
+ say $word ;
+}
+else {
+ say "\"\"" ;
+}
diff --git a/challenge-330/ulrich-rieke/perl/ch-2.pl b/challenge-330/ulrich-rieke/perl/ch-2.pl new file mode 100755 index 0000000000..d5819eff26 --- /dev/null +++ b/challenge-330/ulrich-rieke/perl/ch-2.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+
+say "Enter a string with several words separated by spaces!" ;
+my $line = <STDIN> ;
+chomp $line ;
+my @words = split( /\s/ , $line ) ;
+my @result ;
+for my $w ( @words ) {
+ if ( length( $w ) < 3 ) {
+ push( @result , lc( $w ) ) ;
+ }
+ else {
+ my $word = uc( substr( $w , 0 , 1 )) . lc( substr( $w , 1 ) ) ;
+ push( @result , $word ) ;
+ }
+}
+say join( ' ' , @result) ;
diff --git a/challenge-330/ulrich-rieke/raku/ch-1.raku b/challenge-330/ulrich-rieke/raku/ch-1.raku new file mode 100755 index 0000000000..6f8854f693 --- /dev/null +++ b/challenge-330/ulrich-rieke/raku/ch-1.raku @@ -0,0 +1,14 @@ +use v6 ;
+
+say "Enter a string consisting of lowercase English letters and digits!" ;
+my $word = $*IN.get ;
+while ( $word ~~ /(\D\d)/ ) {
+ my $part = ~$0 ;
+ $word ~~ s/$part// ;
+}
+if ( $word ) {
+ say $word ;
+}
+else {
+ say "\"\"" ;
+}
diff --git a/challenge-330/ulrich-rieke/raku/ch-2.raku b/challenge-330/ulrich-rieke/raku/ch-2.raku new file mode 100755 index 0000000000..17f722bcdb --- /dev/null +++ b/challenge-330/ulrich-rieke/raku/ch-2.raku @@ -0,0 +1,15 @@ +use v6 ;
+
+say "Enter a string with several words separated by space!" ;
+my $line = $*IN.get ;
+my @words = $line.words ;
+my @result ;
+for @words -> $w {
+ if ( $w.chars < 3 ) {
+ @result.push( $w.lc ) ;
+ }
+ else {
+ @result.push( $w.tclc ) ;
+ }
+}
+say @result.join( ' ' ) ;
diff --git a/challenge-330/ulrich-rieke/rust/ch-1.rs b/challenge-330/ulrich-rieke/rust/ch-1.rs new file mode 100755 index 0000000000..42077f69b4 --- /dev/null +++ b/challenge-330/ulrich-rieke/rust/ch-1.rs @@ -0,0 +1,26 @@ +use std::io ; + +fn main() { + println!("Enter a string consisting of lowercase English letters and digits!"); + let mut inline : String = String::new( ) ; + io::stdin( ).read_line( &mut inline ).unwrap( ) ; + let input : &str = inline.trim( ) ; + let mut in_chars : Vec<char> = Vec::new( ) ; + for c in input.chars( ) { + in_chars.push( c ) ; + } + while let Some( pos ) = in_chars.iter( ).position( |c| c.is_digit( 10 ) ) { + if pos > 0 { + in_chars.remove( pos - 1 ) ; + in_chars.remove( pos - 1 ) ; + } + else { + in_chars.remove( 0 ) ; + } + } + let mut result : String = String::new( ) ; + for c in in_chars { + result.push( c ) ; + } + println!("{:?}" , result ) ; +} diff --git a/challenge-330/ulrich-rieke/rust/ch-2.rs b/challenge-330/ulrich-rieke/rust/ch-2.rs new file mode 100755 index 0000000000..a51dde0ee6 --- /dev/null +++ b/challenge-330/ulrich-rieke/rust/ch-2.rs @@ -0,0 +1,37 @@ +use std::io ; + +fn convert( sentence : &str ) -> String { + let words : Vec<&str> = sentence.split_whitespace( ).collect( ) ; + let mut result : String = String::new( ) ; + for w in words { + if w.chars( ).count( ) < 3 { + for c in w.chars( ) { + if c.is_ascii_uppercase( ) { + result.push( c.to_ascii_lowercase( ) ) ; + } + } + } + else { + for c in w.chars( ) { + if c == w.chars( ).nth(0).unwrap( ) { + result.push( c.to_ascii_uppercase( ) ) ; + } + else { + result.push( c.to_ascii_lowercase( ) ) ; + } + } + } + result.push( ' ' ) ; + } + result.pop( ) ; + result +} + + +fn main() { + println!("Enter a string with several words separated by space!"); + let mut inline : String = String::new( ) ; + io::stdin( ).read_line( &mut inline ).unwrap( ) ; + let input : &str = inline.trim( ) ; + println!("{:?}" , convert( input ) ) ; +} diff --git a/stats/pwc-challenge-328.json b/stats/pwc-challenge-328.json index 06838816a6..2b06fa010b 100644 --- a/stats/pwc-challenge-328.json +++ b/stats/pwc-challenge-328.json @@ -147,6 +147,24 @@ { "data" : [ [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Jaldhar H. Vyas", + "name" : "Jaldhar H. Vyas" + }, + { + "data" : [ + [ "Raku", 2 ] @@ -461,6 +479,11 @@ "y" : 2 }, { + "drilldown" : "Jaldhar H. Vyas", + "name" : "Jaldhar H. Vyas", + "y" : 5 + }, + { "drilldown" : "Jan Krnavek", "name" : "Jan Krnavek", "y" : 2 @@ -560,7 +583,7 @@ } ], "subtitle" : { - "text" : "[Champions: 31] Last updated at 2025-07-13 23:28:18 GMT" + "text" : "[Champions: 32] Last updated at 2025-07-15 10:09:36 GMT" }, "title" : { "text" : "The Weekly Challenge - 328" diff --git a/stats/pwc-challenge-329.json b/stats/pwc-challenge-329.json new file mode 100644 index 0000000000..3cfedfdc58 --- /dev/null +++ b/stats/pwc-challenge-329.json @@ -0,0 +1,600 @@ +{ + "chart" : { + "type" : "column" + }, + "drilldown" : { + "series" : [ + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Adam Russell", + "name" : "Adam Russell" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Alexander Karelas", + "name" : "Alexander Karelas" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Ali Moradi", + "name" : "Ali Moradi" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Andreas Mahnke", + "name" : "Andreas Mahnke" + }, + { + "data" : [ + [ + "Raku", + 2 + ] + ], + "id" : "Andrew Shitov", + "name" : "Andrew Shitov" + }, + { + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Arne Sommer", + "name" : "Arne Sommer" + }, + { + "data" : [ + [ + "Perl", + 1 + ], + [ + "Raku", + 1 + ] + ], + "id" : "Athanasius", + "name" : "Athanasius" + }, + { + "data" : [ + [ + "Raku", + 1 + ] + ], + "id" : "BarrOff", + "name" : "BarrOff" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Bob Lied", + "name" : "Bob Lied" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "David Ferrone", + "name" : "David Ferrone" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "E. Choroba", + "name" : "E. Choroba" + }, + { + "data" : [ + [ + "Raku", + 2 + ] + ], + "id" : "Feng Chang", + "name" : "Feng Chang" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Jaldhar H. Vyas", + "name" : "Jaldhar H. Vyas" + }, + { + "data" : [ + [ + "Raku", + 2 + ] + ], + "id" : "Jan Krnavek", + "name" : "Jan Krnavek" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Jorg Sommrey", + "name" : "Jorg Sommrey" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Kjetil Skotheim", + "name" : "Kjetil Skotheim" + }, + { + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 10 + ] + ], + "id" : "Luca Ferrari", + "name" : "Luca Ferrari" + }, + { + "data" : [ + [ + "Raku", + 2 + ] + ], + "id" : "Mark Anderson", + "name" : "Mark Anderson" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Matthias Muth", + "name" : "Matthias Muth" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Niels van Dijke", + "name" : "Niels van Dijke" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Packy Anderson", + "name" : "Packy Anderson" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Peter Meszaros", + "name" : "Peter Meszaros" + }, + { + "data" : [ + [ + "Raku", + 2 + ] + ], + "id" : "Robert Ransbottom", + "name" : "Robert Ransbottom" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Roger Bell_West", + "name" : "Roger Bell_West" + }, + { + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Simon Proctor", + "name" : "Simon Proctor" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 2 + ] + ], + "id" : "Thomas Kohler", + "name" : "Thomas Kohler" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Ulrich Reining", + "name" : "Ulrich Reining" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ], + "id" : "Ulrich Rieke", + "name" : "Ulrich Rieke" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "W. Luis Mochan", + "name" : "W. Luis Mochan" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Wanderdoc", + "name" : "Wanderdoc" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 2 + ] + ], + "id" : "Yitzchak Scott-Thoennes", + "name" : "Yitzchak Scott-Thoennes" + } + ] + }, + "legend" : { + "enabled" : 0 + }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + } + } + }, + "series" : [ + { + "colorByPoint" : 1, + "data" : [ + { + "drilldown" : "Adam Russell", + "name" : "Adam Russell", + "y" : 3 + }, + { + "drilldown" : "Alexander Karelas", + "name" : "Alexander Karelas", + "y" : 2 + }, + { + "drilldown" : "Ali Moradi", + "name" : "Ali Moradi", + "y" : 3 + }, + { + "drilldown" : "Andreas Mahnke", + "name" : "Andreas Mahnke", + "y" : 2 + }, + { + "drilldown" : "Andrew Shitov", + "name" : "Andrew Shitov", + "y" : 2 + }, + { + "drilldown" : "Arne Sommer", + "name" : "Arne Sommer", + "y" : 3 + }, + { + "drilldown" : "Athanasius", + "name" : "Athanasius", + "y" : 2 + }, + { + "drilldown" : "BarrOff", + "name" : "BarrOff", + "y" : 1 + }, + { + "drilldown" : "Bob Lied", + "name" : "Bob Lied", + "y" : 2 + }, + { + "drilldown" : "David Ferrone", + "name" : "David Ferrone", + "y" : 2 + }, + { + "drilldown" : "E. Choroba", + "name" : "E. Choroba", + "y" : 2 + }, + { + "drilldown" : "Feng Chang", + "name" : "Feng Chang", + "y" : 2 + }, + { + "drilldown" : "Jaldhar H. Vyas", + "name" : "Jaldhar H. Vyas", + "y" : 5 + }, + { + "drilldown" : "Jan Krnavek", + "name" : "Jan Krnavek", + "y" : 2 + }, + { + "drilldown" : "Jorg Sommrey", + "name" : "Jorg Sommrey", + "y" : 3 + }, + { + "drilldown" : "Kjetil Skotheim", + "name" : "Kjetil Skotheim", + "y" : 2 + }, + { + "drilldown" : |
