diff options
| author | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-09-08 18:02:30 +0100 |
|---|---|---|
| committer | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-09-08 18:02:30 +0100 |
| commit | 0419e5c69b61c2efff07c39901fd848e6db8a248 (patch) | |
| tree | d9b7cce8e2c63852a004c85423173bf537c6e767 | |
| parent | 6cc30286d62c798a5feddb5453c87fa1d0578ef8 (diff) | |
| download | perlweeklychallenge-club-0419e5c69b61c2efff07c39901fd848e6db8a248.tar.gz perlweeklychallenge-club-0419e5c69b61c2efff07c39901fd848e6db8a248.tar.bz2 perlweeklychallenge-club-0419e5c69b61c2efff07c39901fd848e6db8a248.zip | |
- Added solutions by Peter Campbell Smith.
- Added solutions by E. Choroba.
- Added solutions by Andreas Mahnke.
- Added solutions by David Ferrone.
- Added solutions by PokGoPun.
- Added solutions by Ulrich Rieke.
33 files changed, 408 insertions, 86 deletions
diff --git a/challenge-338/ulrich-rieke/cpp/ch-1.cpp b/challenge-338/ulrich-rieke/cpp/ch-1.cpp new file mode 100755 index 0000000000..7c6f11189a --- /dev/null +++ b/challenge-338/ulrich-rieke/cpp/ch-1.cpp @@ -0,0 +1,36 @@ +#include <vector>
+#include <string>
+#include <iostream>
+#include <numeric>
+#include <algorithm>
+#include <sstream>
+
+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 some integers separated by whitespace , <return> to end!\n" ;
+ std::string line ;
+ std::vector<std::vector<int>> matrix ;
+ std::getline( std::cin , line ) ;
+ while ( ! line.empty( ) ) {
+ std::vector<int> row ;
+ auto tokens { split( line , ' ' ) } ;
+ for ( auto s : tokens )
+ row.push_back( std::stoi( s ) ) ;
+ matrix.push_back( row ) ;
+ std::getline( std::cin , line ) ;
+ }
+ std::vector<int> rowsums ;
+ for ( auto it = matrix.begin( ) ; it != matrix.end( ) ; ++it ) {
+ rowsums.push_back( std::accumulate( it->begin( ) , it->end( ) , 0 )) ;
+ }
+ std::cout << *std::max_element( rowsums.begin( ) , rowsums.end( ) ) << '\n' ;
+ return 0 ;
+}
diff --git a/challenge-338/ulrich-rieke/cpp/ch-2.cpp b/challenge-338/ulrich-rieke/cpp/ch-2.cpp new file mode 100755 index 0000000000..8d869cf127 --- /dev/null +++ b/challenge-338/ulrich-rieke/cpp/ch-2.cpp @@ -0,0 +1,39 @@ +#include <vector>
+#include <string>
+#include <iostream>
+#include <algorithm>
+#include <sstream>
+#include <cstdlib>
+
+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 some integers separated by whitespace!\n" ;
+ std::string line ;
+ std::getline( std::cin , line ) ;
+ auto firsttokens { split( line , ' ' ) } ;
+ std::cout << "Enter some more integers separated by whitespace!\n" ;
+ std::getline( std::cin , line ) ;
+ auto secondtokens { split( line , ' ' ) } ;
+ std::vector<int> firstnums , secondnums , differences ;
+ for ( auto s : firsttokens )
+ firstnums.push_back( std::stoi( s ) ) ;
+ for ( auto s : secondtokens )
+ secondnums.push_back( std::stoi( s ) ) ;
+ for ( auto fit = firstnums.begin( ) ; fit != firstnums.end( ) ; ++fit ) {
+ for ( auto sit = secondnums.begin( ) ; sit != secondnums.end( ) ; ++sit ) {
+ differences.push_back( std::abs( *fit - *sit ) ) ;
+ }
+ }
+ std::cout << *std::max_element( differences.begin( ) , differences.end( ) ) <<
+ '\n' ;
+ return 0 ;
+}
+
diff --git a/challenge-338/ulrich-rieke/haskell/ch-1.hs b/challenge-338/ulrich-rieke/haskell/ch-1.hs new file mode 100755 index 0000000000..592422799a --- /dev/null +++ b/challenge-338/ulrich-rieke/haskell/ch-1.hs @@ -0,0 +1,20 @@ +module Challenge338
+ where
+
+getSomeLines :: IO [String]
+getSomeLines = do
+ line <- getLine
+ if null line then return []
+ else (line : ) <$> getSomeLines
+
+findMaxRow :: [[Int]] -> Int
+findMaxRow = maximum . map sum
+
+main :: IO ( )
+main = do
+ putStrLn "Enter some integers separated by blanks, <return> to end!"
+ allLines <- getSomeLines
+ let matrix = map ( (map read) . words ) allLines
+ print $ findMaxRow matrix
+
+
diff --git a/challenge-338/ulrich-rieke/haskell/ch-2.hs b/challenge-338/ulrich-rieke/haskell/ch-2.hs new file mode 100755 index 0000000000..836bf9c128 --- /dev/null +++ b/challenge-338/ulrich-rieke/haskell/ch-2.hs @@ -0,0 +1,19 @@ +module Challenge338_2
+ where
+
+pairUp :: [Int] -> [Int] -> [(Int , Int)]
+pairUp firstList secondList = [(a , b)| a <- firstList , b <- secondList]
+
+solution :: [Int] -> [Int] -> Int
+solution firstList secondList =
+ let allPairs = pairUp firstList secondList
+ differences = map (\p -> abs( fst p - snd p ) ) allPairs
+ in maximum differences
+
+main :: IO ( )
+main = do
+ putStrLn "Enter some integers separated by whitespace!"
+ firstLine <- getLine
+ putStrLn "Enter some more integers separated by whitespace!"
+ secondLine <- getLine
+ print $ solution ( map read $ words firstLine ) ( map read $ words secondLine )
diff --git a/challenge-338/ulrich-rieke/perl/ch-1.pl b/challenge-338/ulrich-rieke/perl/ch-1.pl new file mode 100755 index 0000000000..5171d0e27a --- /dev/null +++ b/challenge-338/ulrich-rieke/perl/ch-1.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+use List::Util qw( max sum ) ;
+
+say "Enter some integers separated by whitespace, <return> to end!" ;
+my $line = <STDIN> ;
+my @matrix ;
+while ( $line !~ /^$/ ) {
+ chomp $line ;
+ my @numbers = split( /\s+/ , $line ) ;
+ push( @matrix , \@numbers ) ;
+ $line = <STDIN> ;
+}
+my @sums ;
+for my $row( @matrix ) {
+ push( @sums, sum( @{$row} ) ) ;
+}
+say max( @sums ) ;
diff --git a/challenge-338/ulrich-rieke/perl/ch-2.pl b/challenge-338/ulrich-rieke/perl/ch-2.pl new file mode 100755 index 0000000000..6a0765c3b8 --- /dev/null +++ b/challenge-338/ulrich-rieke/perl/ch-2.pl @@ -0,0 +1,23 @@ +#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+use POSIX ;
+use List::Util qw ( max ) ;
+
+say "Enter some integers separated by whitespace!" ;
+my $line = <STDIN> ;
+chomp $line ;
+my @firstnumbers = split( /\s+/ , $line ) ;
+say "Enter some more integers separated by whitespace!" ;
+$line = <STDIN> ;
+chomp $line ;
+my @secondnumbers = split( /\s+/ , $line ) ;
+my @differences ;
+for my $first ( @firstnumbers ) {
+ for my $second ( @secondnumbers ) {
+ push( @differences , abs( $first - $second )) ;
+ }
+}
+say max( @differences ) ;
+
diff --git a/challenge-338/ulrich-rieke/raku/ch-1.raku b/challenge-338/ulrich-rieke/raku/ch-1.raku new file mode 100755 index 0000000000..440e38fd50 --- /dev/null +++ b/challenge-338/ulrich-rieke/raku/ch-1.raku @@ -0,0 +1,15 @@ +use v6 ;
+
+say "Enter some integers separated by whitespace, <return> to end!" ;
+my $line = $*IN.get ;
+my @matrix ;
+while ( $line !~~ /^$/ ) {
+ my @numbers = $line.words.map( {.Int} ) ;
+ @matrix.push( @numbers ) ;
+ $line = $*IN.get ;
+}
+my @sums ;
+for @matrix -> $row {
+ @sums.push( $row.sum ) ;
+}
+say @sums.max ;
diff --git a/challenge-338/ulrich-rieke/raku/ch-2.raku b/challenge-338/ulrich-rieke/raku/ch-2.raku new file mode 100755 index 0000000000..8135ba4e73 --- /dev/null +++ b/challenge-338/ulrich-rieke/raku/ch-2.raku @@ -0,0 +1,15 @@ +use v6 ;
+
+say "Enter some integers separated by whitespace!" ;
+my $line = $*IN.get ;
+my @firstnumbers = $line.words.map( {.Int} ) ;
+say "Enter some more integers separated by whitespace!" ;
+$line = $*IN.get ;
+my @secondnumbers = $line.words.map( {.Int} ) ;
+my @differences ;
+for @firstnumbers -> $first {
+ for @secondnumbers -> $second {
+ @differences.push( abs( $first - $second ) ) ;
+ }
+}
+say @differences.max ;
diff --git a/challenge-338/ulrich-rieke/rust/ch-1.rs b/challenge-338/ulrich-rieke/rust/ch-1.rs new file mode 100755 index 0000000000..ed45575690 --- /dev/null +++ b/challenge-338/ulrich-rieke/rust/ch-1.rs @@ -0,0 +1,31 @@ +use std::io ; +use std::io::BufRead ; + +fn main() -> io::Result<( )> { + println!("Enter some lines of integers , separated by blanks!"); + println!("Enter <return> to end entry!" ) ; + let mut all_input : String = String::new( ) ; + let mut lines = io::stdin( ).lock( ).lines( ) ; + while let Some( line ) = lines.next( ) { + let last_input = line.unwrap( ) ; + if last_input.len( ) == 0 { + break ; + } + else { + all_input.push_str( &last_input ) ; + all_input.push_str( "\n" ) ; + } + } + let total_line : &str = all_input.as_str( ).trim( ) ; + let all_lines : Vec<&str> = total_line.split( "\n" ).collect( ) ; + let mut matrix : Vec<Vec<i32>> = Vec::new( ) ; + for s in &all_lines { + let row : Vec<i32> = s.split_whitespace( ).map( |l| l.parse::<i32>( ).unwrap( )). + collect( ) ; + matrix.push( row.clone( ) ) ; + } + let mut rowsums : Vec<i32> = Vec::new( ) ; + matrix.into_iter( ).map( |r| r.iter( ).sum( )).for_each( |d| rowsums.push( d ) ) ; + println!("{}" , rowsums.into_iter( ).max( ).unwrap( ) ) ; + Ok(()) +} diff --git a/challenge-338/ulrich-rieke/rust/ch-2.rs b/challenge-338/ulrich-rieke/rust/ch-2.rs new file mode 100755 index 0000000000..142be86155 --- /dev/null +++ b/challenge-338/ulrich-rieke/rust/ch-2.rs @@ -0,0 +1,21 @@ +use std::io ; + +fn main() { + println!("Enter some integers separated by whitespace!"); + let mut firstline : String = String::new( ) ; + io::stdin( ).read_line( &mut firstline ).unwrap( ) ; + let firstnumbers : Vec<i32>= firstline.trim( ).split_whitespace( ). + map( |s| s.parse::<i32>( ).unwrap( ) ).collect( ) ; + println!("Enter some more integers separated by whitespace!") ; + let mut secondline : String = String::new( ) ; + io::stdin( ).read_line( &mut secondline ).unwrap( ) ; + let secondnumbers : Vec<i32> = secondline.trim( ).split_whitespace( ). + map( |s| s.parse::<i32>( ).unwrap( )).collect( ) ; + let mut differences : Vec<u32> = Vec::new( ) ; + for m in &firstnumbers { + for n in &secondnumbers { + differences.push( m.abs_diff(*n) ) ; + } + } + println!("{}" , differences.into_iter( ).max( ).unwrap( ) ) ; +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 481e3e557d..4dcbb18d5b 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -21,6 +21,16 @@ { "data" : [ [ + "Perl", + 2 + ] + ], + "id" : "Andreas Mahnke", + "name" : "Andreas Mahnke" + }, + { + "data" : [ + [ "Raku", 2 ] @@ -31,6 +41,26 @@ { "data" : [ [ + "Perl", + 2 + ] + ], + "id" : "David Ferrone", + "name" : "David Ferrone" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "E. Choroba", + "name" : "E. Choroba" + }, + { + "data" : [ + [ "Raku", 2 ] @@ -59,6 +89,34 @@ 1 ] ], + "id" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ], + "id" : "Ulrich Rieke", + "name" : "Ulrich Rieke" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], "id" : "W. Luis Mochan", "name" : "W. Luis Mochan" } @@ -86,11 +144,26 @@ "y" : 3 }, { + "drilldown" : "Andreas Mahnke", + "name" : "Andreas Mahnke", + "y" : 2 + }, + { "drilldown" : "Andrew Shitov", "name" : "Andrew Shitov", "y" : 2 }, { + "drilldown" : "David Ferrone", + "name" : "David Ferrone", + "y" : 2 + }, + { + "drilldown" : "E. Choroba", + "name" : "E. Choroba", + "y" : 2 + }, + { "drilldown" : "Mark Anderson", "name" : "Mark Anderson", "y" : 2 @@ -101,6 +174,16 @@ "y" : 2 }, { + "drilldown" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith", + "y" : 3 + }, + { + "drilldown" : "Ulrich Rieke", + "name" : "Ulrich Rieke", + "y" : 4 + }, + { "drilldown" : "W. Luis Mochan", "name" : "W. Luis Mochan", "y" : 3 @@ -110,7 +193,7 @@ } ], "subtitle" : { - "text" : "[Champions: 5] Last updated at 2025-09-08 10:33:08 GMT" + "text" : "[Champions: 10] Last updated at 2025-09-08 17:02:16 GMT" }, "title" : { "text" : "The Weekly Challenge - 338" diff --git a/stats/pwc-language-breakdown-2019.json b/stats/pwc-language-breakdown-2019.json index aefcbe3eeb..e3f14a0f00 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-08 10:33:08 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-08 17:02:16 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2020.json b/stats/pwc-language-breakdown-2020.json index 3bac3b9ded..a9da3c114b 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-08 10:33:08 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-08 17:02:16 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2021.json b/stats/pwc-language-breakdown-2021.json index 048385fdfe..086015885f 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-08 10:33:08 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-08 17:02:16 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2022.json b/stats/pwc-language-breakdown-2022.json index f31751df6d..2c9af252a9 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-08 10:33:08 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-08 17:02:16 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2023.json b/stats/pwc-language-breakdown-2023.json index 817e92f47f..848a84a089 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-08 10:33:08 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-08 17:02:16 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2024.json b/stats/pwc-language-breakdown-2024.json index 9a6f1c5ebd..a2322dd3e6 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-08 10:33:08 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-08 17:02:16 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2025.json b/stats/pwc-language-breakdown-2025.json index d4bf9c1a1e..d53366bc7c 100644 --- a/stats/pwc-language-breakdown-2025.json +++ b/stats/pwc-language-breakdown-2025.json @@ -8,15 +8,15 @@ "data" : [ [ "Perl", - 6 + 16 ], [ "Raku", - 4 + 6 ], [ "Blog", - 2 + 3 ] ], "id" : "338", @@ -673,7 +673,7 @@ { "drilldown" : "338", "name" : "338", - "y" : 12 + "y" : 25 }, { "drilldown" : "337", @@ -855,7 +855,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-08 10:33:08 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-08 17:02:16 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index e12132a53c..327cb5a0e9 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -10,15 +10,15 @@ "data" : [ [ "Perl", - 17390 + 17400 ], [ "Raku", - 9675 + 9677 ], [ "Blog", - 6247 + 6248 ] ], "dataLabels" : { @@ -37,7 +37,7 @@ } ], "subtitle" : { - "text" : "Last updated at 2025-09-08 10:33:08 GMT" + "text" : "Last updated at 2025-09-08 17:02:16 GMT" }, "title" : { "text" : "The Weekly Challenge Contributions [2019 - 2025]" diff --git a/stats/pwc-leaders.json b/stats/pwc-leaders.json index 1f8950cfd5..7956f39035 100644 --- a/stats/pwc-leaders.json +++ b/stats/pwc-leaders.json @@ -112,11 +112,11 @@ "data" : [ [ "Perl", - 512 + 514 ], [ "Raku", - 520 + 522 ] ], "id" : "Ulrich Rieke", @@ -212,7 +212,7 @@ "data" : [ [ "Perl", - 661 + 663 ], [ "Blog", @@ -276,25 +276,25 @@ "data" : [ [ "Perl", - 594 + 402 + ], + [ + "Blog", + 194 ] ], - "id" : "Paulo Custodio", - "name" : "Paulo Custodio" + "id" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith" }, { "data" : [ [ "Perl", - 400 - ], - [ - "Blog", - 193 + 594 ] ], - "id" : "Peter Campbell Smith", - "name" : "Peter Campbell Smith" + "id" : "Paulo Custodio", + "name" : "Paulo Custodio" }, { "data" : [ @@ -544,33 +544,33 @@ "data" : [ [ "Perl", - 230 + 314 + ], + [ + "Raku", + 13 ], [ "Blog", - 104 + 9 ] ], - "id" : "Matthias Muth", - "name" : "Matthias Muth" + "id" : "David Ferrone", + "name" : "David Ferrone" }, { "data" : [ [ "Perl", - 312 - ], - [ - "Raku", - 13 + 230 ], [ "Blog", - 9 + 104 ] ], - "id" : "David Ferrone", - "name" : "David Ferrone" + "id" : "Matthias Muth", + "name" : "Matthias Muth" }, { "data" : [ @@ -827,7 +827,7 @@ { "drilldown" : "Ulrich Rieke", "name" : "7: Ulrich Rieke", - "y" : 2064 + "y" : 2072 }, { "drilldown" : "Flavio Poletti", @@ -857,7 +857,7 @@ { "drilldown" : "E. Choroba", "name" : "13: E. Choroba", - "y" : 1436 + "y" : 1440 }, { "drilldown" : "Colin Crain", @@ -875,14 +875,14 @@ "y" : 1268 }, { - "drilldown" : "Paulo Custodio", - "name" : "17: Paulo Custodio", - "y" : 1188 + "drilldown" : "Peter Campbell Smith", + "name" : "17: Peter Campbell Smith", + "y" : 1192 }, { - "drilldown" : "Peter Campbell Smith", - "name" : "18: Peter Campbell Smith", - "y" : 1186 + "drilldown" : "Paulo Custodio", + "name" : "18: Paulo Custodio", + "y" : 1188 }, { "drilldown" : "Mark Anderson", @@ -965,13 +965,13 @@ "y" : 674 }, { - "drilldown" : "Matthias Muth", - "name" : "35: Matthias Muth", - "y" : 668 + "drilldown" : "David Ferrone", + "name" : "35: David Ferrone", + "y" : 672 }, { - "drilldown" : "David Ferrone", - "name" : "36: David Ferrone", + "drilldown" : "Matthias Muth", + "name" : "36: Matthias Muth", "y" : 668 }, { @@ -1049,7 +1049,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-09-08 10:33:08 GMT" + "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-09-08 17:02:16 GMT" }, "title" : { "text" : "Team Leaders (TOP 50)" diff --git a/stats/pwc-summary-1-30.json b/stats/pwc-summary-1-30.json index 2177806925..987c62537b 100644 --- a/stats/pwc-summary-1-30.json +++ b/ |
