diff options
| author | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-07-31 11:32:35 +0100 |
|---|---|---|
| committer | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-07-31 11:32:35 +0100 |
| commit | 6f0d16f05f2773a17829abb2db30dff2c2f73444 (patch) | |
| tree | f29b00910b19a20960f88cd6da012e84f61dda29 | |
| parent | 64c63350df166a11e29d5f1447cc5f18965c6665 (diff) | |
| download | perlweeklychallenge-club-6f0d16f05f2773a17829abb2db30dff2c2f73444.tar.gz perlweeklychallenge-club-6f0d16f05f2773a17829abb2db30dff2c2f73444.tar.bz2 perlweeklychallenge-club-6f0d16f05f2773a17829abb2db30dff2c2f73444.zip | |
- Added solutions by Conor Hoekstra.
- Added solutions by Lukas Mai.
- Added solutions by Peter Meszaros.
- Added solutions by Peter Campbell Smith.
- Added solutions by Andrew Shitov.
- Added solutions by David Ferrone.
- Added solutions by E. Choroba.
- Added solutions by Jaldhar H. Vyas.
- Added solutions by Bob Lied.
- Added solutions by Mark Anderson.
- Added solutions by W. Luis Mochan.
- Added solutions by Feng Chang.
- Added solutions by Arne Sommer.
- Added solutions by Simon Proctor.
- Added solutions by HVukamn.
- Added solutions by Benjamin Andre.
- Added solutions by PokGoPun.
- Added solutions by Magnus Markling.
- Added solutions by Roger Bell_West.
- Added solutions by Athanasius.
- Added solutions by Robbie Hatley.
- Added solutions by Packy Anderson.
- Added solutions by Ali Moradi.
- Added solutions by Thomas Kohler.
56 files changed, 1072 insertions, 439 deletions
diff --git a/challenge-322/conor-hoekstra/ch-1.bqn b/challenge-322/conor-hoekstra/bqn/ch-1.bqn index 3af00f74a2..3af00f74a2 100644 --- a/challenge-322/conor-hoekstra/ch-1.bqn +++ b/challenge-322/conor-hoekstra/bqn/ch-1.bqn diff --git a/challenge-322/conor-hoekstra/ch-2.bqn b/challenge-322/conor-hoekstra/bqn/ch-2.bqn index b981bdfb46..b981bdfb46 100644 --- a/challenge-322/conor-hoekstra/ch-2.bqn +++ b/challenge-322/conor-hoekstra/bqn/ch-2.bqn diff --git a/challenge-323/conor-hoekstra/ch-1.bqn b/challenge-323/conor-hoekstra/bqn/ch-1.bqn index 92b237f6e6..92b237f6e6 100644 --- a/challenge-323/conor-hoekstra/ch-1.bqn +++ b/challenge-323/conor-hoekstra/bqn/ch-1.bqn diff --git a/challenge-323/conor-hoekstra/ch-2.bqn b/challenge-323/conor-hoekstra/bqn/ch-2.bqn index ce480bc8b6..ce480bc8b6 100644 --- a/challenge-323/conor-hoekstra/ch-2.bqn +++ b/challenge-323/conor-hoekstra/bqn/ch-2.bqn diff --git a/challenge-325/conor-hoekstra/ch-1.bqn b/challenge-325/conor-hoekstra/bqn/ch-1.bqn index 6f90bf0bb6..6f90bf0bb6 100644 --- a/challenge-325/conor-hoekstra/ch-1.bqn +++ b/challenge-325/conor-hoekstra/bqn/ch-1.bqn diff --git a/challenge-325/conor-hoekstra/ch-2.bqn b/challenge-325/conor-hoekstra/bqn/ch-2.bqn index d0b28e2e1c..d0b28e2e1c 100644 --- a/challenge-325/conor-hoekstra/ch-2.bqn +++ b/challenge-325/conor-hoekstra/bqn/ch-2.bqn diff --git a/challenge-326/conor-hoekstra/ch-1.bqn b/challenge-326/conor-hoekstra/bqn/ch-1.bqn index 82bf18819c..82bf18819c 100644 --- a/challenge-326/conor-hoekstra/ch-1.bqn +++ b/challenge-326/conor-hoekstra/bqn/ch-1.bqn diff --git a/challenge-326/conor-hoekstra/ch-2.bqn b/challenge-326/conor-hoekstra/bqn/ch-2.bqn index 6c5d6bae36..6c5d6bae36 100644 --- a/challenge-326/conor-hoekstra/ch-2.bqn +++ b/challenge-326/conor-hoekstra/bqn/ch-2.bqn diff --git a/challenge-327/conor-hoekstra/ch-1.bqn b/challenge-327/conor-hoekstra/bqn/ch-1.bqn index 7eadad6fa0..7eadad6fa0 100644 --- a/challenge-327/conor-hoekstra/ch-1.bqn +++ b/challenge-327/conor-hoekstra/bqn/ch-1.bqn diff --git a/challenge-327/conor-hoekstra/ch-2.bqn b/challenge-327/conor-hoekstra/bqn/ch-2.bqn index 49a89bff11..49a89bff11 100644 --- a/challenge-327/conor-hoekstra/ch-2.bqn +++ b/challenge-327/conor-hoekstra/bqn/ch-2.bqn diff --git a/challenge-328/conor-hoekstra/ch-1.bqn b/challenge-328/conor-hoekstra/bqn/ch-1.bqn index 8e9c0f3940..8e9c0f3940 100644 --- a/challenge-328/conor-hoekstra/ch-1.bqn +++ b/challenge-328/conor-hoekstra/bqn/ch-1.bqn diff --git a/challenge-328/conor-hoekstra/ch-2.bqn b/challenge-328/conor-hoekstra/bqn/ch-2.bqn index ca327cbb52..ca327cbb52 100644 --- a/challenge-328/conor-hoekstra/ch-2.bqn +++ b/challenge-328/conor-hoekstra/bqn/ch-2.bqn diff --git a/challenge-329/conor-hoekstra/ch-1.bqn b/challenge-329/conor-hoekstra/bqn/ch-1.bqn index 277bb3075f..277bb3075f 100644 --- a/challenge-329/conor-hoekstra/ch-1.bqn +++ b/challenge-329/conor-hoekstra/bqn/ch-1.bqn diff --git a/challenge-329/conor-hoekstra/ch-2.bqn b/challenge-329/conor-hoekstra/bqn/ch-2.bqn index f8790bb56a..f8790bb56a 100644 --- a/challenge-329/conor-hoekstra/ch-2.bqn +++ b/challenge-329/conor-hoekstra/bqn/ch-2.bqn diff --git a/challenge-330/conor-hoekstra/ch-1.bqn b/challenge-330/conor-hoekstra/bqn/ch-1.bqn index 5ad557215e..5ad557215e 100644 --- a/challenge-330/conor-hoekstra/ch-1.bqn +++ b/challenge-330/conor-hoekstra/bqn/ch-1.bqn diff --git a/challenge-330/conor-hoekstra/ch-2.bqn b/challenge-330/conor-hoekstra/bqn/ch-2.bqn index 6ce167b686..6ce167b686 100644 --- a/challenge-330/conor-hoekstra/ch-2.bqn +++ b/challenge-330/conor-hoekstra/bqn/ch-2.bqn diff --git a/challenge-331/conor-hoekstra/ch-1.bqn b/challenge-331/conor-hoekstra/bqn/ch-1.bqn index 09610d2384..09610d2384 100644 --- a/challenge-331/conor-hoekstra/ch-1.bqn +++ b/challenge-331/conor-hoekstra/bqn/ch-1.bqn diff --git a/challenge-331/conor-hoekstra/ch-2.bqn b/challenge-331/conor-hoekstra/bqn/ch-2.bqn index b78af76790..b78af76790 100644 --- a/challenge-331/conor-hoekstra/ch-2.bqn +++ b/challenge-331/conor-hoekstra/bqn/ch-2.bqn diff --git a/challenge-332/conor-hoekstra/ch-1.bqn b/challenge-332/conor-hoekstra/bqn/ch-1.bqn index 599b81e01d..599b81e01d 100644 --- a/challenge-332/conor-hoekstra/ch-1.bqn +++ b/challenge-332/conor-hoekstra/bqn/ch-1.bqn diff --git a/challenge-332/conor-hoekstra/ch-2.bqn b/challenge-332/conor-hoekstra/bqn/ch-2.bqn index c7dd75f124..c7dd75f124 100644 --- a/challenge-332/conor-hoekstra/ch-2.bqn +++ b/challenge-332/conor-hoekstra/bqn/ch-2.bqn diff --git a/challenge-332/eric-cheung/python/ch-1.py b/challenge-332/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..08082990c1 --- /dev/null +++ b/challenge-332/eric-cheung/python/ch-1.py @@ -0,0 +1,8 @@ +
+## strInputDate = "2025-07-26" ## Example 1
+## strInputDate = "2000-02-02" ## Example 2
+strInputDate = "2024-12-31" ## Example 3
+
+arrBinDate = ["{0:b}".format(int(strElem)) for strElem in strInputDate.split("-")]
+
+print ("-".join(arrBinDate))
diff --git a/challenge-332/eric-cheung/python/ch-2.py b/challenge-332/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..15f4df85a9 --- /dev/null +++ b/challenge-332/eric-cheung/python/ch-2.py @@ -0,0 +1,8 @@ +
+## strInput = "weekly" ## Example 1
+## strInput = "perl" ## Example 2
+strInput = "challenge" ## Example 3
+
+arrSet = [charLoop for charLoop in set(strInput) if strInput.count(charLoop) % 2 == 0]
+
+print (len(arrSet) == 0)
diff --git a/challenge-332/ulrich-rieke/cpp/ch-1.cpp b/challenge-332/ulrich-rieke/cpp/ch-1.cpp new file mode 100755 index 0000000000..0af0824971 --- /dev/null +++ b/challenge-332/ulrich-rieke/cpp/ch-1.cpp @@ -0,0 +1,49 @@ +#include <iostream>
+#include <vector>
+#include <sstream>
+#include <string>
+#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 ;
+}
+
+std::string to_binary_string( int part ) {
+ std::string binary ;
+ while ( part != 0 ) {
+ if ( part % 2 == 1 ) {
+ binary.push_back( '1' ) ;
+ }
+ else {
+ binary.push_back( '0' ) ;
+ }
+ part /= 2 ;
+ }
+ std::reverse( binary.begin( ) , binary.end( )) ;
+ return binary ;
+}
+
+int main( ) {
+ std::cout << "Enter a date as year-month-day!\n" ;
+ std::string date ;
+ std::getline( std::cin , date ) ;
+ auto dateparts { split( date , '-' ) } ;
+ std::vector<std::string> transformed ;
+ for ( auto part : dateparts ) {
+ int numdate = std::stoi( part ) ;
+ transformed.push_back( to_binary_string( numdate ) ) ;
+ }
+ std::string solution ;
+ for ( auto s : transformed ) {
+ solution += s ;
+ solution.push_back( '-' ) ;
+ }
+ solution.pop_back( ) ;
+ std::cout << solution << '\n' ;
+ return 0 ;
+}
diff --git a/challenge-332/ulrich-rieke/cpp/ch-2.cpp b/challenge-332/ulrich-rieke/cpp/ch-2.cpp new file mode 100755 index 0000000000..272df141ee --- /dev/null +++ b/challenge-332/ulrich-rieke/cpp/ch-2.cpp @@ -0,0 +1,17 @@ +#include <iostream>
+#include <string>
+#include <algorithm>
+#include <map>
+
+int main( ) {
+ std::cout << "Enter a word!\n" ;
+ std::string word ;
+ std::getline( std::cin , word ) ;
+ std::map<char , int> frequencies ;
+ for ( char c : word )
+ frequencies[c]++ ;
+ std::cout << std::boolalpha << std::all_of( frequencies.begin( ) ,
+ frequencies.end( ) , []( const auto & p ) { return p.second % 2 ==
+ 1 ; } ) << '\n' ;
+ return 0 ;
+}
diff --git a/challenge-332/ulrich-rieke/haskell/ch-1.hs b/challenge-332/ulrich-rieke/haskell/ch-1.hs new file mode 100755 index 0000000000..ed4190b6a1 --- /dev/null +++ b/challenge-332/ulrich-rieke/haskell/ch-1.hs @@ -0,0 +1,20 @@ +module Challenge332
+ where
+import Data.List ( intercalate )
+import Data.List.Split ( splitOn )
+
+toBinaryString :: Int -> String
+toBinaryString part = reverse $ snd $ until ( (== 0 ). fst ) step ( part ,"" )
+ where
+ step :: (Int , String) -> (Int , String )
+ step ( currentNumber, binary ) = ( div currentNumber 2 , binary ++
+ show ( mod currentNumber 2 ) )
+
+convert :: String -> String
+convert = intercalate "-" . map ( toBinaryString . read ) . splitOn "-"
+
+main :: IO ( )
+main = do
+ putStrLn "Enter a date in the form year-month-day!"
+ date <- getLine
+ print $ convert date
diff --git a/challenge-332/ulrich-rieke/haskell/ch-2.hs b/challenge-332/ulrich-rieke/haskell/ch-2.hs new file mode 100755 index 0000000000..d8deaf60a0 --- /dev/null +++ b/challenge-332/ulrich-rieke/haskell/ch-2.hs @@ -0,0 +1,18 @@ +module Challenge332_2
+ where
+import qualified Data.Set as S
+
+count :: Eq a => a -> [a] -> Int
+count _ [] = 0
+count d ( x:xs )
+ |d == x = 1 + count d xs
+ |otherwise = count d xs
+
+solution :: String -> Bool
+solution word = all odd $ map (\l -> count l word ) $ S.toList $ S.fromList word
+
+main :: IO ( )
+main = do
+ putStrLn "Enter a word!"
+ word <- getLine
+ print $ solution word
diff --git a/challenge-332/ulrich-rieke/perl/ch-1.pl b/challenge-332/ulrich-rieke/perl/ch-1.pl new file mode 100755 index 0000000000..f1fc7a9069 --- /dev/null +++ b/challenge-332/ulrich-rieke/perl/ch-1.pl @@ -0,0 +1,11 @@ +#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+
+say "Enter a date as year-month-day!" ;
+my $date = <STDIN> ;
+chomp $date ;
+my @dateparts = split( /\-/ , $date ) ;
+my @transformed = map { sprintf("%b" , $_) } @dateparts ;
+say join( '-' , @transformed ) ;
diff --git a/challenge-332/ulrich-rieke/perl/ch-2.pl b/challenge-332/ulrich-rieke/perl/ch-2.pl new file mode 100755 index 0000000000..4f8581a6c9 --- /dev/null +++ b/challenge-332/ulrich-rieke/perl/ch-2.pl @@ -0,0 +1,17 @@ +#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+use List::Util qw ( all ) ;
+
+say "Enter a word!" ;
+my $word = <STDIN> ;
+chomp $word ;
+my %frequencies ;
+map { $frequencies{$_}++ } split( // , $word ) ;
+if ( all { $_ % 2 == 1 } values %frequencies ) {
+ say "true" ;
+}
+else {
+ say "false" ;
+}
diff --git a/challenge-332/ulrich-rieke/raku/ch-1.raku b/challenge-332/ulrich-rieke/raku/ch-1.raku new file mode 100755 index 0000000000..13c56719f8 --- /dev/null +++ b/challenge-332/ulrich-rieke/raku/ch-1.raku @@ -0,0 +1,7 @@ +use v6 ;
+
+say "Enter a date as year-month-day!" ;
+my $date = $*IN.get ;
+my @dateparts = $date.split( / '-' / ) ;
+my @transformed = @dateparts.map( { (+$_).base( 2 ) } ) ;
+say @transformed.join( '-' ) ;
diff --git a/challenge-332/ulrich-rieke/raku/ch-2.raku b/challenge-332/ulrich-rieke/raku/ch-2.raku new file mode 100755 index 0000000000..4ff5f5c8e4 --- /dev/null +++ b/challenge-332/ulrich-rieke/raku/ch-2.raku @@ -0,0 +1,7 @@ +use v6 ;
+
+say "Enter a word!" ;
+my $word = $*IN.get ;
+my %frequencies ;
+$word.comb.map( {%frequencies{$_}++ } ) ;
+say %frequencies.values.elems == %frequencies.values.grep( {$_ % 2 == 1} ).elems;
diff --git a/challenge-332/ulrich-rieke/rust/ch-1.rs b/challenge-332/ulrich-rieke/rust/ch-1.rs new file mode 100755 index 0000000000..389c07e8b4 --- /dev/null +++ b/challenge-332/ulrich-rieke/rust/ch-1.rs @@ -0,0 +1,30 @@ +use std::io ; + +fn to_binary_string( date : &str ) -> String { + let mut binary : String = String::new( ) ; + let mut date_num : usize = date.parse::<usize>( ).unwrap( ) ; + while date_num != 0 { + if date_num % 2 == 1 { + binary.insert_str( 0 , "1" ) ; + } + else { + binary.insert_str( 0 , "0" ) ; + } + date_num /= 2 ; + } + binary +} + +fn main() { + println!("Enter a date as year-month-day!"); + let mut inline : String = String::new( ) ; + io::stdin( ).read_line( &mut inline ).unwrap( ) ; + let parts : Vec<&str> = inline.trim( ).split( "-" ).collect( ) ; + let mut result : String = String::new( ) ; + parts.into_iter( ).map( |s| to_binary_string( s ) ).for_each( |date| { + result += &date[..] ; + result.push( '-' ) ; + } ) ; + result.pop( ) ; + println!("{:?}" , result ) ; +} diff --git a/challenge-332/ulrich-rieke/rust/ch-2.rs b/challenge-332/ulrich-rieke/rust/ch-2.rs new file mode 100755 index 0000000000..f9001cf8d5 --- /dev/null +++ b/challenge-332/ulrich-rieke/rust/ch-2.rs @@ -0,0 +1,14 @@ +use std::io ; +use std::collections::HashMap ; + +fn main() { + println!("Enter a word!"); + let mut inline : String = String::new( ) ; + io::stdin( ).read_line( &mut inline ).unwrap( ) ; + let mut frequencies : HashMap<char , usize> = HashMap::new( ) ; + for c in inline.trim( ).chars( ) { + frequencies.entry( c ).and_modify( |counter| *counter += 1 ). + or_insert( 1 ) ; + } + println!("{}" , frequencies.values( ).all( |n| n % 2 == 1 ) ) ; +} diff --git a/stats/pwc-challenge-331.json b/stats/pwc-challenge-331.json new file mode 100644 index 0000000000..fd040ad2e2 --- /dev/null +++ b/stats/pwc-challenge-331.json @@ -0,0 +1,645 @@ +{ + "chart" : { + "type" : "column" + }, + "drilldown" : { + "series" : [ + { + "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", + 2 + ], + [ + "Raku", + 2 + ] + ], + "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", + |
