diff options
| author | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-09-29 23:01:45 +0100 |
|---|---|---|
| committer | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-09-29 23:01:45 +0100 |
| commit | 23d40ecd816cf620b0124b6e11788b1cd42523a9 (patch) | |
| tree | 6b6f96e4c041d23cf821012f1b7da6d27aab73e2 | |
| parent | 07d357205ad222c1f538b587c30e4f39ed486596 (diff) | |
| download | perlweeklychallenge-club-23d40ecd816cf620b0124b6e11788b1cd42523a9.tar.gz perlweeklychallenge-club-23d40ecd816cf620b0124b6e11788b1cd42523a9.tar.bz2 perlweeklychallenge-club-23d40ecd816cf620b0124b6e11788b1cd42523a9.zip | |
- Added solutions by Andreas Mahnke.
- Added solutions by Peter Meszaros.
- Added solutions by Richard Park.
- Added solutions by Ulrich Rieke.
- Added solutions by W. Luis Mochan.
- Added solutions by Matthias Muth.
33 files changed, 374 insertions, 76 deletions
diff --git a/challenge-341/ulrich-rieke/cpp/ch-1.cpp b/challenge-341/ulrich-rieke/cpp/ch-1.cpp new file mode 100755 index 0000000000..3864478e92 --- /dev/null +++ b/challenge-341/ulrich-rieke/cpp/ch-1.cpp @@ -0,0 +1,33 @@ +#include <iostream>
+#include <sstream>
+#include <vector>
+#include <algorithm>
+#include <string>
+
+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 ;
+}
+
+bool condition( const std::string & word , const std::vector<std::string> &
+ forbidden ) {
+ return std::all_of( forbidden.begin( ) , forbidden.end( ) , [word]( const auto & w ) {
+ return word.find( w ) == std::string::npos ; } ) ;
+}
+
+int main( ) {
+ std::cout << "Enter some words with English letters only!\n" ;
+ std::string line ;
+ std::getline( std::cin , line ) ;
+ auto words { split( line , ' ' ) } ;
+ std::cout << "Enter some letters , separated by whitespace!\n" ;
+ std::getline( std::cin , line ) ;
+ auto letters { split( line , ' ' ) } ;
+ std::cout << std::count_if( words.begin( ) , words.end( ) , [&letters](const auto & w) {
+ return condition( w , letters ) ; } ) << '\n' ;
+ return 0 ;
+}
diff --git a/challenge-341/ulrich-rieke/cpp/ch-2.cpp b/challenge-341/ulrich-rieke/cpp/ch-2.cpp new file mode 100755 index 0000000000..88c5d6eb4c --- /dev/null +++ b/challenge-341/ulrich-rieke/cpp/ch-2.cpp @@ -0,0 +1,30 @@ +#include <iostream>
+#include <sstream>
+#include <string>
+#include <vector>
+#include <algorithm>
+
+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 and a letter from that string!\n" ;
+ std::string line ;
+ std::getline( std::cin , line ) ;
+ auto tokens { split( line , ' ' ) } ;
+ auto search_in { tokens[0] } ;
+ auto search_for { tokens[1] } ;
+ auto pos = search_in.find( search_for ) ;
+ auto secondPart = search_in.substr( pos + 1 ) ;
+ auto firstPart = search_in.substr( 0 , pos + 1 ) ;
+ std::reverse( firstPart.begin( ) , firstPart.end( ) ) ;
+ std::string result { firstPart + secondPart } ;
+ std::cout << result << '\n' ;
+ return 0 ;
+}
diff --git a/challenge-341/ulrich-rieke/haskell/ch-1.hs b/challenge-341/ulrich-rieke/haskell/ch-1.hs new file mode 100755 index 0000000000..36cc969784 --- /dev/null +++ b/challenge-341/ulrich-rieke/haskell/ch-1.hs @@ -0,0 +1,15 @@ +module Challenge341
+ where
+import Data.List ( findIndices )
+
+condition :: String -> String -> Bool
+condition str forbidden = all (\l -> null $ findIndices ( == l ) forbidden ) str
+
+main :: IO ( )
+main = do
+ putStrLn "Enter a line with words consisting of English letters only!"
+ allWords <- getLine
+ putStrLn "Enter a line with letters separated by whitespace!"
+ letterLine <- getLine
+ let letters = map head $ words letterLine
+ print $ length $ filter ( flip condition letters ) $ words allWords
diff --git a/challenge-341/ulrich-rieke/haskell/ch-2.hs b/challenge-341/ulrich-rieke/haskell/ch-2.hs new file mode 100755 index 0000000000..8a52f88e28 --- /dev/null +++ b/challenge-341/ulrich-rieke/haskell/ch-2.hs @@ -0,0 +1,20 @@ +module Challenge341_2
+ where
+import Data.List ( findIndex )
+import Data.Maybe ( fromJust )
+
+solution :: [String] -> String
+solution input = (reverse $ take ( pos + 1 ) first) ++ drop ( pos + 1 ) first
+ where
+ first :: String
+ first = head input
+ letter :: Char
+ letter = head $ last input
+ pos :: Int
+ pos = fromJust $ findIndex ( == letter ) first
+
+main :: IO ( )
+main = do
+ putStrLn "Enter a string and a letter from that string!"
+ inputLine <- getLine
+ print $ solution $ words inputLine
diff --git a/challenge-341/ulrich-rieke/perl/ch-1.pl b/challenge-341/ulrich-rieke/perl/ch-1.pl new file mode 100755 index 0000000000..3f43c9f032 --- /dev/null +++ b/challenge-341/ulrich-rieke/perl/ch-1.pl @@ -0,0 +1,27 @@ +#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+
+sub condition {
+ my $word = shift ;
+ my $forbidden = shift ;
+ for my $letter( split(// , $word ) ) {
+ if ( exists( $forbidden->{$letter} ) ) {
+ return 0 ;
+ }
+ }
+ return 1 ;
+}
+
+say "Enter a sentence with English letters only!" ;
+my $sentence = <STDIN> ;
+chomp $sentence ;
+my @words = split( /\s/ , $sentence ) ;
+say "Enter some letters separated by whitespace!" ;
+my $letterline = <STDIN> ;
+chomp $letterline ;
+my @letters = split( // , $letterline ) ;
+my %notWanted ;
+map { $notWanted{$_}++ } @letters ;
+say scalar( grep { condition( $_, \%notWanted ) } @words ) ;
diff --git a/challenge-341/ulrich-rieke/perl/ch-2.pl b/challenge-341/ulrich-rieke/perl/ch-2.pl new file mode 100755 index 0000000000..a45fbc8472 --- /dev/null +++ b/challenge-341/ulrich-rieke/perl/ch-2.pl @@ -0,0 +1,13 @@ +#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+
+say "Enter a word and a letter from this word!" ;
+my $line = <STDIN> ;
+chomp $line ;
+my ($search_in , $search_for) = split( /\s/ , $line ) ;
+my $pos = index($search_in , $search_for) ;
+my $firstPart = join( '' , reverse split( // , substr( $search_in , 0 , $pos + 1))) ;
+my $secondPart = substr( $search_in , $pos + 1 ) ;
+say $firstPart . $secondPart ;
diff --git a/challenge-341/ulrich-rieke/raku/ch-1.raku b/challenge-341/ulrich-rieke/raku/ch-1.raku new file mode 100755 index 0000000000..4c83dc2aac --- /dev/null +++ b/challenge-341/ulrich-rieke/raku/ch-1.raku @@ -0,0 +1,19 @@ +use v6 ;
+
+sub condition( $word , $letterset ) {
+ for $word.comb -> $letter {
+ if ( $letter (elem) $letterset ) {
+ return False ;
+ }
+ }
+ return True ;
+}
+
+say "Enter a sentence with English letters only!" ;
+my $sentence = $*IN.get ;
+my @words = $sentence.words ;
+say "Enter some letters separated by whitespace!" ;
+my $line = $*IN.get ;
+my @letters = $line.words ;
+my $forbidden = @letters.Set ;
+say @words.grep( {condition( $_ , $forbidden)} ).elems ;
diff --git a/challenge-341/ulrich-rieke/raku/ch-2.raku b/challenge-341/ulrich-rieke/raku/ch-2.raku new file mode 100755 index 0000000000..3f2e228821 --- /dev/null +++ b/challenge-341/ulrich-rieke/raku/ch-2.raku @@ -0,0 +1,11 @@ +use v6 ;
+
+say "Enter a string and a letter from this string!" ;
+my $line = $*IN.get ;
+my @words = $line.words ;
+my $search_in = @words[0] ;
+my $search_for = @words[1] ;
+my $pos = $search_in.index( $search_for ) ;
+my $firstPart = $search_in.substr( 0 , $pos + 1 ).comb.reverse.join( ) ;
+my $secondPart = $search_in.substr( $pos + 1 ) ;
+say $firstPart ~ $secondPart ;
diff --git a/challenge-341/ulrich-rieke/rust/ch-1.rs b/challenge-341/ulrich-rieke/rust/ch-1.rs new file mode 100755 index 0000000000..2d62398dcd --- /dev/null +++ b/challenge-341/ulrich-rieke/rust/ch-1.rs @@ -0,0 +1,21 @@ +use std::io ; + +fn main() { + println!("Enter a string with English letters only!"); + let mut firstline : String = String::new( ) ; + io::stdin( ).read_line( &mut firstline ).unwrap( ) ; + let first_words : Vec<&str> = firstline.trim( ).split_whitespace( ).collect( ) ; + println!("Enter some letters separated by whitespace!") ; + let mut secondline : String = String::new( ) ; + io::stdin( ).read_line( &mut secondline ).unwrap( ) ; + let second_words : Vec<&str> = secondline.trim( ).split_whitespace( ).collect() ; + let mut forbidden_chars : Vec<char> = Vec::new( ) ; + for w in &second_words { + for c in w.chars( ) { + forbidden_chars.push( c ) ; + } + } + println!("{}" , first_words.into_iter( ).filter( |&w| { + w.chars( ).all( |c| ! forbidden_chars.contains( &c ) ) + }).count( ) ) ; +} diff --git a/challenge-341/ulrich-rieke/rust/ch-2.rs b/challenge-341/ulrich-rieke/rust/ch-2.rs new file mode 100755 index 0000000000..81136b4b9d --- /dev/null +++ b/challenge-341/ulrich-rieke/rust/ch-2.rs @@ -0,0 +1,22 @@ +use std::io ; + +fn main() { + println!("Enter a string and a letter from that string!"); + let mut inline : String = String::new( ) ; + io::stdin( ).read_line( &mut inline ).unwrap( ) ; + let words : Vec<&str> = inline.trim( ).split_whitespace( ).collect( ) ; + let search_in : &str = words[0] ; + let search_for : &str = words[1] ; + let pos : usize = search_in.find( search_for).unwrap( ) ; + let mut final_string : String = String::new( ) ; + let mut p : usize = pos ; + while p != 0 { + final_string.push( search_in.chars( ).nth( p ).unwrap( ) ) ; + p -= 1 ; + } + final_string.push( search_in.chars( ).nth( 0 ).unwrap( )) ; + for c in search_in.chars( ).skip( pos + 1 ) { + final_string.push( c ) ; + } + println!("{:?}" , final_string) ; +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index a729906d29..096a43cdbb 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -7,6 +7,16 @@ { "data" : [ [ + "Perl", + 2 + ] + ], + "id" : "Andreas Mahnke", + "name" : "Andreas Mahnke" + }, + { + "data" : [ + [ "Raku", 2 ] @@ -78,6 +88,20 @@ "data" : [ [ "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Matthias Muth", + "name" : "Matthias Muth" + }, + { + "data" : [ + [ + "Perl", 1 ] ], @@ -117,6 +141,44 @@ ], "id" : "Peter Campbell Smith", "name" : "Peter Campbell Smith" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Peter Meszaros", + "name" : "Peter Meszaros" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ], + "id" : "Ulrich Rieke", + "name" : "Ulrich Rieke" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "W. Luis Mochan", + "name" : "W. Luis Mochan" } ] }, @@ -137,6 +199,11 @@ "colorByPoint" : 1, "data" : [ { + "drilldown" : "Andreas Mahnke", + "name" : "Andreas Mahnke", + "y" : 2 + }, + { "drilldown" : "Andrew Shitov", "name" : "Andrew Shitov", "y" : 2 @@ -172,6 +239,11 @@ "y" : 2 }, { + "drilldown" : "Matthias Muth", + "name" : "Matthias Muth", + "y" : 3 + }, + { "drilldown" : "Mohammad Sajid Anwar", "name" : "Mohammad Sajid Anwar", "y" : 1 @@ -190,13 +262,28 @@ "drilldown" : "Peter Campbell Smith", "name" : "Peter Campbell Smith", "y" : 3 + }, + { + "drilldown" : "Peter Meszaros", + "name" : "Peter Meszaros", + "y" : 2 + }, + { + "drilldown" : "Ulrich Rieke", + "name" : "Ulrich Rieke", + "y" : 4 + }, + { + "drilldown" : "W. Luis Mochan", + "name" : "W. Luis Mochan", + "y" : 3 } ], "name" : "The Weekly Challenge - 341" } ], "subtitle" : { - "text" : "[Champions: 11] Last updated at 2025-09-29 12:44:20 GMT" + "text" : "[Champions: 16] Last updated at 2025-09-29 22:01:19 GMT" }, "title" : { "text" : "The Weekly Challenge - 341" diff --git a/stats/pwc-language-breakdown-2019.json b/stats/pwc-language-breakdown-2019.json index 09521d449d..fe27b626a6 100644 --- a/stats/pwc-language-breakdown-2019.json +++ b/stats/pwc-language-breakdown-2019.json @@ -970,7 +970,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-29 12:44:20 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-29 22:01:19 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2020.json b/stats/pwc-language-breakdown-2020.json index 7394712962..ede622e1ab 100644 --- a/stats/pwc-language-breakdown-2020.json +++ b/stats/pwc-language-breakdown-2020.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-29 12:44:20 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-29 22:01:19 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2021.json b/stats/pwc-language-breakdown-2021.json index 69daea8cb5..65b03d2f0b 100644 --- a/stats/pwc-language-breakdown-2021.json +++ b/stats/pwc-language-breakdown-2021.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-29 12:44:20 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-29 22:01:19 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2022.json b/stats/pwc-language-breakdown-2022.json index 7c2fdc057a..e997f4606d 100644 --- a/stats/pwc-language-breakdown-2022.json +++ b/stats/pwc-language-breakdown-2022.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-29 12:44:20 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-29 22:01:19 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2023.json b/stats/pwc-language-breakdown-2023.json index 4b58b767ad..437a5463f9 100644 --- a/stats/pwc-language-breakdown-2023.json +++ b/stats/pwc-language-breakdown-2023.json @@ -1200,7 +1200,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-29 12:44:20 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-29 22:01:19 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2024.json b/stats/pwc-language-breakdown-2024.json index eee888dd3e..0e967a0b24 100644 --- a/stats/pwc-language-breakdown-2024.json +++ b/stats/pwc-language-breakdown-2024.json @@ -1246,7 +1246,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-29 12:44:20 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-29 22:01:19 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2025.json b/stats/pwc-language-breakdown-2025.json index fc96a205f5..b5990390c2 100644 --- a/stats/pwc-language-breakdown-2025.json +++ b/stats/pwc-language-breakdown-2025.json @@ -8,15 +8,15 @@ "data" : [ [ "Perl", - 15 + 25 ], [ "Raku", - 6 + 8 ], [ "Blog", - 1 + 3 ] ], "id" : "341", @@ -727,7 +727,7 @@ { "drilldown" : "341", "name" : "341", - "y" : 22 + "y" : 36 }, { "drilldown" : "340", @@ -924,7 +924,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-29 12:44:20 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-29 22:01:19 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index e735bff643..fdc11f55de 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -10,15 +10,15 @@ "data" : [ [ "Perl", - 17548 + 17558 ], [ "Raku", - 9749 + 9751 ], [ "Blog", - 6285 + 6287 ] ], "dataLabels" : { @@ -37,7 +37,7 @@ } ], "subtitle" : { - "text" : "Last updated at 2025-09-29 12:44:20 GMT" + "text" : "Last updated at 2025-09-29 22:01:19 GMT" }, "title" : { "text" : "The Weekly Challenge Contributions [2019 - 2025]" diff --git a/stats/pwc-leaders.json b/stats/pwc-leaders.json index 0492dfa983..36eb634538 100644 --- a/stats/pwc-leaders.json +++ b/stats/pwc-leaders.json @@ -112,11 +112,11 @@ "data" : [ [ "Perl", - 518 + 520 ], [ "Raku", - 526 + 528 ] ], "id" : "Ulrich Rieke", @@ -144,37 +144,37 @@ "data" : [ [ "Perl", - 550 + 500 ], [ "Raku", - 1 + 2 ], [ "Blog", - 199 + 250 ] ], - "id" : "Dave Jacoby", - "name" : "Dave Jacoby" + "id" : "W. Luis Mochan", + "name" : "W. Luis Mochan" }, { "data" : [ [ "Perl", - 498 + 550 ], [ "Raku", - 2 + 1 ], [ "Blog", - 249 + 199 ] ], - "id" : "W. Luis Mochan", - "name" : "W. Luis Mochan" + "id" : "Dave Jacoby", + "name" : "Dave Jacoby" }, { "data" : [ @@ -526,11 +526,11 @@ "data" : [ [ "Perl", - 236 + 238 ], [ "Blog", - 107 + 108 ] ], "id" : "Matthias Muth", @@ -646,7 +646,7 @@ "data" : [ [ "Perl", - 282 + 284 ] ], "id" : "Peter Meszaros", @@ -827,7 +827,7 @@ { "drilldown" : "Ulrich Rieke", "name" : "7: Ulrich Rieke", - "y" : 2088 + "y" : 2096 }, { "drilldown" : "Flavio Poletti", @@ -835,14 +835,14 @@ "y" : 1716 }, { - "drilldown" : "Dave Jacoby", - "name" : "9: Dave Jacoby", - "y" : 1500 + "drilldown" : "W. Luis Mochan", + "name" : "9: W. Luis Mochan", + "y" : 1504 }, { - "drilldown" : "W. Luis Mochan", - "name" : "10: W. Luis Mochan", - "y" : 1498 + "drilldown" : "Dave Jacoby", + "name" : "10: Dave Jacoby", + "y" : 1500 }, { "drilldown" : "Jorg Sommrey", @@ -962,7 +962,7 @@ { "drilldown" : "Matthias Muth", "name" : "34: Matthias Muth", - "y" : 686 + "y" : 692 }, { "drilldown" : "David Ferrone", @@ -1002,7 +1002,7 @@ { "drilldown" : "Peter Meszaros", "name" : "42: Peter Meszaros", - "y" : 564 + "y" : 568 }, { "drilldown" : "Stephen G. Lynn", @@ -1049,7 +1049,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-09-29 12:44:20 GMT" + "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-09-29 22:01:19 GMT" }, "title" : { "text" : "Team Leaders (TOP 50)" diff --git a/stats/pwc-summary-1-30.json b/stats/pwc-summary-1-30.json index ac98e6a4d7..50573bf195 100644 --- a/stats/pwc-summary-1-30.json +++ b/stats/pwc-summary-1-30.json @@ -28,7 +28,7 @@ 44, 13, 8, - 80, + 82, 22, 8, 1, @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-09-29 12:44:20 GMT" + "text" : "[Champions: 30] Last updated at 2025-09-29 22:01:19 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-121-150.json b/stats/pwc-summary-121-150.json index ca4e1fc9e0..fb1ef8dac6 100644 --- a/stats/pwc-summary-121-150.json +++ b/stats/pwc-summary-121-150.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-09-29 12:44:20 GMT" + "text" : "[Champions: 30] Last updated at 2025-09-29 22:01:19 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-151-180.json b/stats/pwc-summary-151-180.json index 994dad60ea..cd63066c20 100644 --- a/stats/pwc-summary-151-180.json +++ b/stats/pwc-summary-151-180.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-0 |
