diff options
31 files changed, 3004 insertions, 2479 deletions
diff --git a/challenge-258/eric-cheung/python/ch-1.py b/challenge-258/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..ece02350ec --- /dev/null +++ b/challenge-258/eric-cheung/python/ch-1.py @@ -0,0 +1,7 @@ +
+## arrInt = [10, 1, 111, 24, 1000] ## Example 1
+## arrInt = [111, 1, 11111] ## Example 2
+arrInt = [2, 8, 1024, 256] ## Example 3
+
+arrOutput = [elemLoop for elemLoop in arrInt if len(str(elemLoop)) % 2 == 0]
+print (len(arrOutput))
diff --git a/challenge-258/eric-cheung/python/ch-2.py b/challenge-258/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..a6088a474b --- /dev/null +++ b/challenge-258/eric-cheung/python/ch-2.py @@ -0,0 +1,15 @@ +
+## Example 1
+## arrInt = [2, 5, 9, 11, 3]
+## nInput = 1
+
+## Example 2
+## arrInt = [2, 5, 9, 11, 3]
+## nInput = 2
+
+## Example 3
+arrInt = [2, 5, 9, 11, 3]
+nInput = 0
+
+arrOutput = [elemLoop for nIndx, elemLoop in enumerate(arrInt) if bin(nIndx)[2:].count("1") == nInput]
+print (sum(arrOutput))
diff --git a/challenge-258/perlboy1967/perl/ch1.pl b/challenge-258/perlboy1967/perl/ch-1.pl index 7b12ee6549..7b12ee6549 100755 --- a/challenge-258/perlboy1967/perl/ch1.pl +++ b/challenge-258/perlboy1967/perl/ch-1.pl diff --git a/challenge-258/perlboy1967/perl/ch2.pl b/challenge-258/perlboy1967/perl/ch-2.pl index 0c7501df71..0c7501df71 100755 --- a/challenge-258/perlboy1967/perl/ch2.pl +++ b/challenge-258/perlboy1967/perl/ch-2.pl diff --git a/challenge-258/ulrich-rieke/cpp/ch-1.cpp b/challenge-258/ulrich-rieke/cpp/ch-1.cpp new file mode 100755 index 0000000000..5fd1356674 --- /dev/null +++ b/challenge-258/ulrich-rieke/cpp/ch-1.cpp @@ -0,0 +1,18 @@ +#include <vector>
+#include <string>
+#include <algorithm>
+#include <iterator>
+#include <iostream>
+
+int main( ) {
+ std::cout << "Enter some integers, separated by spaces!\n" ;
+ std::cout << "Enter 'e' to end entry!\n" ;
+ std::vector<int> numbers { std::istream_iterator<int>{ std::cin } ,
+ std::istream_iterator<int>{} } ;
+ std::vector<std::string> numberstrings ;
+ for ( int i : numbers )
+ numberstrings.push_back( std::to_string( i ) ) ;
+ std::cout << std::count_if( numberstrings.begin( ) , numberstrings.end( ),
+ []( auto s ) { return s.length( ) % 2 == 0 ; } ) << '\n' ;
+ return 0 ;
+}
diff --git a/challenge-258/ulrich-rieke/cpp/ch-2.cpp b/challenge-258/ulrich-rieke/cpp/ch-2.cpp new file mode 100755 index 0000000000..bfc4fae901 --- /dev/null +++ b/challenge-258/ulrich-rieke/cpp/ch-2.cpp @@ -0,0 +1,37 @@ +#include <iostream>
+#include <algorithm>
+#include <vector>
+#include <iterator>
+
+//unfortunately, my compiler neither supports the function popcount,
+//defined in <bit> , nor the header file <format> , defined in C++20!
+//So I have to come up with this helper function!
+std::vector<int> toBinary( int n ) {
+ std::vector<int> digits ;
+ while ( n != 0 ) {
+ digits.push_back( n % 2 ) ;
+ n /= 2 ;
+ }
+ return digits ;
+}
+
+int main( ) {
+ //I reverse the order of data entry in order to preserve the beautiful
+ //way of entering a vector of integers by simply invoking the
+ //constructors of an input stream!
+ std::cout << "Enter an integer k!\n" ;
+ int k ;
+ std::cin >> k ;
+ std::cout << "Enter some integers, separated by spaces!\n" ;
+ std::cout << "Enter 'e' to end entry!\n" ;
+ std::vector<int> numbers {std::istream_iterator<int>{std::cin} ,
+ std::istream_iterator<int>{} } ;
+ int sum = 0 ;
+ for ( int i = 0 ; i < numbers.size( ) ; i++ ) {
+ std::vector<int> digits { toBinary( i ) } ;
+ if ( std::count( digits.begin( ) , digits.end( ) , 1 ) == k )
+ sum += numbers[i] ;
+ }
+ std::cout << sum << '\n' ;
+ return 0 ;
+}
diff --git a/challenge-258/ulrich-rieke/haskell/ch-1.hs b/challenge-258/ulrich-rieke/haskell/ch-1.hs new file mode 100755 index 0000000000..9cd2d9c969 --- /dev/null +++ b/challenge-258/ulrich-rieke/haskell/ch-1.hs @@ -0,0 +1,11 @@ +module Challenge258
+ where
+
+solution :: String -> Int
+solution = length . filter even . map length . words
+
+main :: IO ( )
+main = do
+ putStrLn "Enter some integers separated by spaces!"
+ numbers <- getLine
+ print $ solution numbers
diff --git a/challenge-258/ulrich-rieke/haskell/ch-2.hs b/challenge-258/ulrich-rieke/haskell/ch-2.hs new file mode 100755 index 0000000000..bbdacd1d02 --- /dev/null +++ b/challenge-258/ulrich-rieke/haskell/ch-2.hs @@ -0,0 +1,17 @@ +module Challenge258_2
+ where
+import Data.Bits
+
+solution :: [Int] -> Int -> Int
+solution list ones = sum $ map snd $ filter ((== ones ) . popCount . fst )
+ $ zip ([0,1..] ::[Int] ) list
+
+main :: IO ( )
+main = do
+ putStrLn "Enter some integers, separated by spaces!" ;
+ numberline <- getLine
+ putStrLn "Enter an integer k!"
+ kVal <- getLine
+ let numbers = map read $ words numberline
+ k = read kVal
+ print $ solution numbers k
diff --git a/challenge-258/ulrich-rieke/perl/ch-1.pl b/challenge-258/ulrich-rieke/perl/ch-1.pl new file mode 100755 index 0000000000..46ca14c52a --- /dev/null +++ b/challenge-258/ulrich-rieke/perl/ch-1.pl @@ -0,0 +1,7 @@ +use v5.36.0 ;
+
+say "Enter some integers separated by spaces!" ;
+my $line = <STDIN> ;
+chomp $line ;
+my @numbers = split( /\s+/ , $line ) ;
+say scalar( grep { length( $_ ) % 2 == 0 } @numbers ) ;
diff --git a/challenge-258/ulrich-rieke/perl/ch-2.pl b/challenge-258/ulrich-rieke/perl/ch-2.pl new file mode 100755 index 0000000000..4f6a0bced8 --- /dev/null +++ b/challenge-258/ulrich-rieke/perl/ch-2.pl @@ -0,0 +1,19 @@ +use v5.36.0 ;
+
+say "Enter some integers, separated by spaces!" ;
+my $line = <STDIN> ;
+chomp $line ;
+my @numbers = split( /\s+/ , $line ) ;
+say "Enter another integer!" ;
+my $k = <STDIN> ;
+chomp $k ;
+my $sum = 0 ;
+my $len = scalar( @numbers ) ;
+for my $i (0..$len - 1 ) {
+ my $binary = sprintf "%b" , $i ;
+ my @suitables = grep { $_ eq '1' } split( // , $binary ) ;
+ if ( scalar( @suitables ) == $k ) {
+ $sum += $numbers[ $i ] ;
+ }
+}
+say $sum ;
diff --git a/challenge-258/ulrich-rieke/raku/ch-1.raku b/challenge-258/ulrich-rieke/raku/ch-1.raku new file mode 100755 index 0000000000..3421996b85 --- /dev/null +++ b/challenge-258/ulrich-rieke/raku/ch-1.raku @@ -0,0 +1,6 @@ +use v6 ;
+
+say "Enter some integers, separated by spaces!" ;
+my $line = $*IN.get ;
+my @numbers = $line.words ;
+say @numbers.grep( {$_.chars %% 2} ).elems ;
diff --git a/challenge-258/ulrich-rieke/raku/ch-2.raku b/challenge-258/ulrich-rieke/raku/ch-2.raku new file mode 100755 index 0000000000..6e9a8a7ef5 --- /dev/null +++ b/challenge-258/ulrich-rieke/raku/ch-2.raku @@ -0,0 +1,17 @@ +use v6 ;
+
+say "Enter some integers , separated by spaces!" ;
+my $line = $*IN.get ;
+my @numbers = $line.words.map( {.Int} ) ;
+say "Enter another integer!" ;
+$line = $*IN.get ;
+my $k = $line.Int ;
+my $sum = 0 ;
+my $len = @numbers.elems ;
+for (0..$len - 1 ) -> $i {
+ my @digits = $i.base( 2 ).comb.map( {.Int} ) ;
+ if ( @digits.grep( { $_ == 1 } ).elems == $k ) {
+ $sum += @numbers[ $i ] ;
+ }
+}
+say $sum ;
diff --git a/challenge-258/ulrich-rieke/rust/ch-1.rs b/challenge-258/ulrich-rieke/rust/ch-1.rs new file mode 100755 index 0000000000..e70bc0cbb6 --- /dev/null +++ b/challenge-258/ulrich-rieke/rust/ch-1.rs @@ -0,0 +1,13 @@ +use std::io ; + +fn main() { + println!("Enter some positive integers, separated by spaces!"); + let mut inline : String = String::new( ) ; + io::stdin( ).read_line( &mut inline ).unwrap( ) ; + let entered_line : &str = &*inline ; + let numbers : Vec<&str> = entered_line.split_whitespace( ).map( | s | + s.trim( )).collect( ) ; + let result = numbers.iter( ).filter( | &x | x.len( ) % 2 == 0 ). + count( ) ; + println!("{}" , result) ; +} diff --git a/challenge-258/ulrich-rieke/rust/ch-2.rs b/challenge-258/ulrich-rieke/rust/ch-2.rs new file mode 100755 index 0000000000..9ebfac3a74 --- /dev/null +++ b/challenge-258/ulrich-rieke/rust/ch-2.rs @@ -0,0 +1,22 @@ +use std::io ; + +fn main() { + println!("Enter a number of integers, separated by spaces!"); + let mut inline : String = String::new( ) ; + io::stdin( ).read_line( &mut inline ).unwrap( ) ; + let entered_line : &str = &*inline ; + let numbers : Vec<i32> = entered_line.split_whitespace( ).map( | s | + s.trim( ).parse::<i32>( ).unwrap( ) ).collect( ) ; + println!("Enter another integer!") ; + let mut line : String = String::new( ) ; + io::stdin( ).read_line( &mut line ).unwrap( ) ; + let second_line : &str = &*line ; + let number : u32 = second_line.trim( ).parse::<u32>( ).unwrap( ) ; + let mut sum : i32 = 0 ; + for i in 0..numbers.len( ) { + if i.count_ones( ) == number { + sum += numbers[ i ] ; + } + } + println!("{}" , sum ) ; +} diff --git a/stats/pwc-challenge-257.json b/stats/pwc-challenge-257.json new file mode 100644 index 0000000000..4b70b172bc --- /dev/null +++ b/stats/pwc-challenge-257.json @@ -0,0 +1,548 @@ +{ + "xAxis" : { + "type" : "category" + }, + "title" : { + "text" : "The Weekly Challenge - 257" + }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "series" : [ + { + "colorByPoint" : 1, + "name" : "The Weekly Challenge - 257", + "data" : [ + { + "drilldown" : "Arne Sommer", + "name" : "Arne Sommer", + "y" : 3 + }, + { + "drilldown" : "Athanasius", + "name" : "Athanasius", + "y" : 4 + }, + { + "name" : "BarrOff", + "drilldown" : "BarrOff", + "y" : 2 + }, + { + "y" : 2, + "drilldown" : "Bob Lied", + "name" : "Bob Lied" + }, + { + "name" : "Bruce Gray", + "drilldown" : "Bruce Gray", + "y" : 2 + }, + { + "y" : 3, + "drilldown" : "Dave Jacoby", + "name" : "Dave Jacoby" + }, + { + "drilldown" : "David Ferrone", + "name" : "David Ferrone", + "y" : 2 + }, + { + "drilldown" : "E. Choroba", + "name" : "E. Choroba", + "y" : 2 + }, + { + "drilldown" : "Jaldhar H. Vyas", + "name" : "Jaldhar H. Vyas", + "y" : 5 + }, + { + "y" : 1, + "name" : "Jan Krnavek", + "drilldown" : "Jan Krnavek" + }, + { + "y" : 3, + "drilldown" : "Jorg Sommrey", + "name" : "Jorg Sommrey" + }, + { + "y" : 5, + "name" : "Laurent Rosenfeld", + "drilldown" : "Laurent Rosenfeld" + }, + { + "y" : 4, + "drilldown" : "Lubos Kolouch", + "name" : "Lubos Kolouch" + }, + { + "y" : 11, + "drilldown" : "Luca Ferrari", + "name" : "Luca Ferrari" + }, + { + "drilldown" : "Mariano Spadaccini", + "name" : "Mariano Spadaccini", + "y" : 1 + }, + { + "drilldown" : "Mark Anderson", + "name" : "Mark Anderson", + "y" : 2 + }, + { + "name" : "Matthew Neleigh", + "drilldown" : "Matthew Neleigh", + "y" : 2 + }, + { + "y" : 2, + "drilldown" : "Nelo Tovar", + "name" : "Nelo Tovar" + }, + { + "y" : 5, + "name" : "Packy Anderson", + "drilldown" : "Packy Anderson" + }, + { + "name" : "Peter Campbell Smith", + "drilldown" : "Peter Campbell Smith", + "y" : 3 + }, + { + "y" : 2, + "drilldown" : "Peter Meszaros", + "name" : "Peter Meszaros" + }, + { + "drilldown" : "Robbie Hatley", + "name" : "Robbie Hatley", + "y" : 1 + }, + { + "y" : 5, + "drilldown" : "Roger Bell_West", + "name" : "Roger Bell_West" + }, + { + "y" : 3, + "drilldown" : "Simon Green", + "name" : "Simon Green" + }, + { + "drilldown" : "Stephen G. Lynn", + "name" : "Stephen G. Lynn", + "y" : 1 + }, + { + "name" : "Thomas Kohler", + "drilldown" : "Thomas Kohler", + "y" : 4 + }, + { + "drilldown" : "Ulrich Rieke", + "name" : "Ulrich Rieke", + "y" : 3 + }, + { + "y" : 3, + "drilldown" : "W. Luis Mochan", + "name" : "W. Luis Mochan" + } + ] + } + ], + "subtitle" : { + "text" : "[Champions: 28] Last updated at 2024-02-27 12:03:11 GMT" + }, + "tooltip" : { + "followPointer" : 1, + "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", + "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>" + }, + "legend" : { + "enabled" : 0 + }, + "drilldown" : { + "series" : [ + { + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Arne Sommer", + "name" : "Arne Sommer" + }, + { + "name" : "Athanasius", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ], + "id" : "Athanasius" + }, + { + "name" : "BarrOff", + "id" : "BarrOff", + "data" : [ + [ + "Perl", + 1 + ], + [ + "Raku", + 1 + ] + ] + }, + { + "name" : "Bob Lied", + "id" : "Bob Lied", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "name" : "Bruce Gray", + "data" : [ + [ + "Raku", + 2 + ] + ], + "id" : "Bruce Gray" + }, + { + "name" : "Dave Jacoby", + "id" : "Dave Jacoby", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "name" : "David Ferrone", + "id" : "David Ferrone", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "id" : "E. Choroba", + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "E. Choroba" + }, + { + "name" : "Jaldhar H. Vyas", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Jaldhar H. Vyas" + }, + { + "data" : [ + [ + "Raku", + 1 + ] + ], + "id" : "Jan Krnavek", + "name" : "Jan Krnavek" + }, + { + "name" : "Jorg Sommrey", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Jorg Sommrey" + }, + { + "id" : "Laurent Rosenfeld", + "data" : [ + [ + "Perl", + 1 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 2 + ] + ], + "name" : "Laurent Rosenfeld" + }, + { + "name" : "Lubos Kolouch", + "id" : "Lubos Kolouch", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ] + }, + { + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 9 + ] + ], + "id" : "Luca Ferrari", + "name" : "Luca Ferrari" + }, + { + "name" : "Mariano Spadaccini", + "id" : "Mariano Spadaccini", + "data" : [ + [ + "Perl", + 1 + ] + ] + }, + { + "name" : "Mark Anderson", + "id" : "Mark Anderson", + "data" : [ + [ + "Raku", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Matthew Neleigh", + "name" : "Matthew Neleigh" + }, + { + "name" : "Nelo Tovar", + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Nelo Tovar" + }, + { + "name" : "Packy Anderson", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Packy Anderson" + }, + { + "name" : "Peter Campbell Smith", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Peter Campbell Smith" + }, + { + "name" : "Peter Meszaros", + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Peter Meszaros" + }, + { + "name" : "Robbie Hatley", + "id" : "Robbie Hatley", + "data" : [ + [ + "Perl", + 1 + ] + ] + }, + { + "id" : "Roger Bell_West", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Roger Bell_West" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Simon Green", + "name" : "Simon Green" + }, + { + "name" : "Stephen G. Lynn", + "data" : [ + [ + "Perl", + 1 + ] + ], + "id" : "Stephen G. Lynn" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 2 + ] + ], + "id" : "Thomas Kohler", + "name" : "Thomas Kohler" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 1 + ] + ], + "id" : "Ulrich Rieke", + "name" : "Ulrich Rieke" + }, + { + "name" : "W. Luis Mochan", + "id" : "W. Luis Mochan", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + } + ] + }, + "chart" : { + "type" : "column" + } +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 9fa56d88f9..67692f8ab3 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,10 +1,4 @@ { - "xAxis" : { - "type" : "category" - }, - "chart" : { - "type" : "column" - }, "plotOptions" : { "series" : { "dataLabels" : { @@ -14,73 +8,97 @@ "borderWidth" : 0 } }, + "xAxis" : { + "type" : "category" + }, + "series" : [ + { + "data" : [ + { + "drilldown" : "Dave Jacoby", + "y" : 3, + "name" : "Dave Jacoby" + }, + { + "drilldown" : "David Ferrone", + "y" : 2, + "name" : "David Ferrone" + }, + { + "drilldown" : "E. Choroba", + "y" : 2, + "name" : "E. Choroba" + }, + { + "drilldown" : "Luca Ferrari", + "y" : 11, + "name" : "Luca Ferrari" + }, + { + "name" : "Mariano Spadaccini", + "y" : 2, + "drilldown" : "Mariano Spadaccini" + }, + { + "name" : "Matthew Neleigh", + "drilldown" : "Matthew Neleigh", + "y" : 2 + }, + { + "drilldown" : "Niels van Dijke", + "y" : 2, + "name" : "Niels van Dijke" + }, + { + "y" : 3, + "drilldown" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith" + }, + { + "y" : 2, + "drilldown" : "Peter Meszaros", + "name" : "Peter Meszaros" + }, + { + "drilldown" : "Roger Bell_West", + "y" : 4, + "name" : "Roger Bell_West" + }, + { + "name" : "Ryan Thompson", + "y" : 4, + "drilldown" : "Ryan Thompson" + }, + { + "drilldown" : "Thomas Kohler", + "y" : 4, + "name" : "Thomas Kohler" + }, + { + "name" : "Ulrich Rieke", + "drilldown" : "Ulrich Rieke", + "y" : 4 + }, + { + "name" : "W. Luis Mochan", + "drilldown" : "W. Luis Mochan", + "y" : 3 + } + ], + "name" : "The Weekly Challenge - 258", + "c |
