diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-01-04 15:55:04 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-01-04 15:55:04 +0000 |
| commit | 771b67fe896d14f2244e14255e847aa34a3e5a7e (patch) | |
| tree | 0363761a5d0a77a2b5a3bf2d6738f171d85275ae | |
| parent | eea272843353377e3256b5767a01f01cda874cb3 (diff) | |
| download | perlweeklychallenge-club-771b67fe896d14f2244e14255e847aa34a3e5a7e.tar.gz perlweeklychallenge-club-771b67fe896d14f2244e14255e847aa34a3e5a7e.tar.bz2 perlweeklychallenge-club-771b67fe896d14f2244e14255e847aa34a3e5a7e.zip | |
- Added solutions by Ulrich Rieke.
- Added solutions by Simon Proctor.
- Added solutions by Roger Bell_West.
- Added solutions by Arne Sommer.
- Added solutions by Matthew Neleigh.
- Added solutions by David Ferrone.
- Added solutions by Peter Campbell Smith.
26 files changed, 2975 insertions, 2618 deletions
diff --git a/challenge-250/ulrich-rieke/cpp/ch-1.cpp b/challenge-250/ulrich-rieke/cpp/ch-1.cpp new file mode 100755 index 0000000000..79e5d6ad1e --- /dev/null +++ b/challenge-250/ulrich-rieke/cpp/ch-1.cpp @@ -0,0 +1,39 @@ +#include <vector>
+#include <iostream>
+#include <algorithm>
+#include <string>
+
+std::vector<std::string> split( const std::string & startline ,
+ const std::string & sep ) {
+ std::vector<std::string> separated ;
+ std::string::size_type start { 0 } ;
+ std::string::size_type pos ;
+ do {
+ pos = startline.find_first_of( sep , start ) ;
+ separated.push_back( startline.substr(start , pos - start )) ;
+ start = pos + 1 ;
+ } while ( pos != std::string::npos ) ;
+ return separated ;
+}
+
+int main( ) {
+ std::cout << "Enter some integers, separated by blanks!\n" ;
+ std::string line ;
+ std::getline( std::cin , line ) ;
+ std::vector<std::string> numberstrings( split( line , " " ) ) ;
+ std::vector<int> numbers ;
+ for ( auto s : numberstrings )
+ numbers.push_back( std::stoi( s ) ) ;
+ std::vector<int> selected ;
+ for ( int i = 0 ; i < numbers.size( ) ; i++ ) {
+ if ( i % 10 == numbers[ i ] )
+ selected.push_back( i ) ;
+ }
+ if ( selected.size( ) > 0 )
+ std::cout << *std::min_element( selected.begin( ) , selected.end( ) ) ;
+ else {
+ std::cout << -1 ;
+ }
+ std::cout << std::endl ;
+ return 0 ;
+}
diff --git a/challenge-250/ulrich-rieke/cpp/ch-2.cpp b/challenge-250/ulrich-rieke/cpp/ch-2.cpp new file mode 100755 index 0000000000..3366da7ecf --- /dev/null +++ b/challenge-250/ulrich-rieke/cpp/ch-2.cpp @@ -0,0 +1,43 @@ +#include <vector>
+#include <iostream>
+#include <string>
+#include <algorithm>
+#include <cctype>
+
+std::vector<std::string> split( const std::string & startline ,
+ const std::string & sep ) {
+ std::vector<std::string> separated ;
+ std::string::size_type start { 0 } ;
+ std::string::size_type pos ;
+ do {
+ pos = startline.find_first_of( sep , start ) ;
+ separated.push_back( startline.substr(start , pos - start )) ;
+ start = pos + 1 ;
+ } while ( pos != std::string::npos ) ;
+ return separated ;
+}
+
+int convert( const std::string & s ) {
+ if ( std::any_of( s.begin( ) , s.end( ) , []( auto c ){ return
+ std::isalpha( c ) ; } ) ) {
+ return s.length( ) ;
+ }
+ else {
+ return std::stoi( s ) ;
+ }
+}
+
+int main( ) {
+ std::cout << "Please enter some strings, separated by blanks!\n" ;
+ std::string line ;
+ std::getline( std::cin , line ) ;
+ std::vector<std::string> allStrings { split( line , " " ) } ;
+ std::vector<int> nums ( allStrings.size( ) ) ;
+ std::transform( allStrings.begin( ) , allStrings.end( ) ,
+ nums.begin( ) , convert ) ;
+ std::cout << *std::max_element( nums.begin( ) , nums.end( )) <<
+ std::endl ;
+ return 0 ;
+}
+
+
diff --git a/challenge-250/ulrich-rieke/haskell/ch-1.hs b/challenge-250/ulrich-rieke/haskell/ch-1.hs new file mode 100755 index 0000000000..5223b4abc7 --- /dev/null +++ b/challenge-250/ulrich-rieke/haskell/ch-1.hs @@ -0,0 +1,8 @@ +module Challenge250
+ where
+
+solution :: [Int] -> Int
+solution list = if null selected then -1 else minimum selected
+ where
+ selected = map fst $ filter (\p -> fst p `mod` 10 == snd p ) $ zip [0..] list
+
diff --git a/challenge-250/ulrich-rieke/haskell/ch-2.hs b/challenge-250/ulrich-rieke/haskell/ch-2.hs new file mode 100755 index 0000000000..d195d5a20d --- /dev/null +++ b/challenge-250/ulrich-rieke/haskell/ch-2.hs @@ -0,0 +1,15 @@ +module Challenge250_2
+ where
+import Data.Char ( isLetter )
+
+convert :: String -> Int
+convert s = if any isLetter s then length s else read s
+
+solution :: String -> Int
+solution = maximum . map convert . words
+
+main :: IO ( )
+main = do
+ putStrLn "Please enter some strings, separated by blanks!"
+ strings <- getLine
+ print $ solution strings
diff --git a/challenge-250/ulrich-rieke/perl/ch-1.pl b/challenge-250/ulrich-rieke/perl/ch-1.pl new file mode 100755 index 0000000000..01465f3e36 --- /dev/null +++ b/challenge-250/ulrich-rieke/perl/ch-1.pl @@ -0,0 +1,22 @@ +#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+use List::Util qw ( min ) ;
+
+say "Enter some integers separated by blanks!" ;
+my $line = <STDIN> ;
+chomp $line ;
+my @numbers = split( /\s/ , $line ) ;
+my @selected ;
+for my $pos ( 0..scalar( @numbers ) - 1 ) {
+ if ( $pos % 10 == $numbers[ $pos ] ) {
+ push @selected , $pos ;
+ }
+}
+if ( @selected ) {
+ say min( @selected ) ;
+}
+else {
+ say -1 ;
+}
diff --git a/challenge-250/ulrich-rieke/perl/ch-2.pl b/challenge-250/ulrich-rieke/perl/ch-2.pl new file mode 100755 index 0000000000..92b7af750e --- /dev/null +++ b/challenge-250/ulrich-rieke/perl/ch-2.pl @@ -0,0 +1,25 @@ +#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+use List::Util qw ( max ) ;
+
+sub convert {
+ my $string = shift ;
+ if ( $string =~ /\D/ ) {
+ return length $string ;
+ }
+ else {
+ return ($string + 0) ;
+ }
+}
+
+say "Enter some strings, separated by blanks!" ;
+my $line = <STDIN> ;
+chomp $line ;
+my @strings = split( /\s/ , $line ) ;
+my @converted ;
+for my $s ( @strings ) {
+ push @converted , convert( $s ) ;
+}
+say max( @converted ) ;
diff --git a/challenge-250/ulrich-rieke/raku/ch-1.raku b/challenge-250/ulrich-rieke/raku/ch-1.raku new file mode 100755 index 0000000000..7aae7c6b75 --- /dev/null +++ b/challenge-250/ulrich-rieke/raku/ch-1.raku @@ -0,0 +1,17 @@ +use v6 ;
+
+say "Enter some integers, separated by blanks!" ;
+my $line = $*IN.get ;
+my @numbers = $line.words.map( {.Int} ) ;
+my @selected ;
+for (0..@numbers.elems - 1 ) -> $pos {
+ if ( $pos % 10 == @numbers[ $pos ] ) {
+ @selected.push( $pos ) ;
+ }
+}
+if ( @selected ) {
+ say @selected.min ;
+}
+else {
+ say "-1" ;
+}
diff --git a/challenge-250/ulrich-rieke/raku/ch-2.raku b/challenge-250/ulrich-rieke/raku/ch-2.raku new file mode 100755 index 0000000000..2206682cef --- /dev/null +++ b/challenge-250/ulrich-rieke/raku/ch-2.raku @@ -0,0 +1,17 @@ +use v6 ;
+
+sub convert( $aString ) {
+ if ( $aString ~~ /\D/ ) {
+ return $aString.chars ;
+ }
+ else {
+ return $aString.Int ;
+ }
+}
+
+say "Enter some strings, separated by blanks!" ;
+my $line = $*IN.get ;
+my @strings = $line.words ;
+my @converted ;
+@strings.map( { @converted.push( convert( $_ ) ) } ) ;
+say @converted.max ;
diff --git a/challenge-250/ulrich-rieke/rust/ch-1.rs b/challenge-250/ulrich-rieke/rust/ch-1.rs new file mode 100755 index 0000000000..7d8d5a7a31 --- /dev/null +++ b/challenge-250/ulrich-rieke/rust/ch-1.rs @@ -0,0 +1,23 @@ +use std::io ; + +fn main() { + println!("Enter some integers, separated by blanks!"); + 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( ) ; + let mut selected : Vec<usize> = Vec::new( ) ; + let len = numbers.len( ) ; + for i in 0..len { + if i % 10 == numbers[ i ] as usize { + selected.push( i ) ; + } + } + if selected.len( ) > 0 { + println!("{}" , selected.iter( ).min( ).unwrap( ) ) ; + } + else { + println!("-1") ; + } +} diff --git a/challenge-250/ulrich-rieke/rust/ch-2.rs b/challenge-250/ulrich-rieke/rust/ch-2.rs new file mode 100755 index 0000000000..2e96e6eda3 --- /dev/null +++ b/challenge-250/ulrich-rieke/rust/ch-2.rs @@ -0,0 +1,23 @@ +use std::io ; + +fn convert( term : &&str ) -> usize { + if term.chars( ).all( | d | d.is_digit( 10 )) { + term.parse::<usize>( ).unwrap( ) + } + else { + term.chars( ).count( ) + } +} + +fn main() { + println!("Please enter some strings , separated by words!"); + let mut inline : String = String::new( ) ; + io::stdin( ).read_line( &mut inline ).unwrap( ) ; + let entered_line : &str = &*inline ; + let terms : Vec<&str> = entered_line.split_whitespace( ).map( | s | + s.trim( ) ).collect( ) ; + let mut converted : Vec<usize> = Vec::new( ) ; + terms.iter( ).map( | w | convert( &w ) ).for_each( | d | + converted.push( d ) ) ; + println!("{}" , converted.iter( ).max( ).unwrap( ) ) ; +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index f4829b3cd5..3f6f064253 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,89 +1,20 @@ { - "chart" : { - "type" : "column" + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } }, "subtitle" : { - "text" : "[Champions: 13] Last updated at 2024-01-02 12:36:13 GMT" + "text" : "[Champions: 20] Last updated at 2024-01-04 15:50:20 GMT" }, - "xAxis" : { - "type" : "category" + "title" : { + "text" : "The Weekly Challenge - 250" }, - "series" : [ - { - "name" : "The Weekly Challenge - 250", - "colorByPoint" : 1, - "data" : [ - { - "drilldown" : "Ali Moradi", - "name" : "Ali Moradi", - "y" : 5 - }, - { - "y" : 2, - "drilldown" : "Bob Lied", - "name" : "Bob Lied" - }, - { - "name" : "Dave Jacoby", - "drilldown" : "Dave Jacoby", - "y" : 3 - }, - { - "y" : 2, - "name" : "David Ferrone", - "drilldown" : "David Ferrone" - }, - { - "y" : 2, - "name" : "E. Choroba", - "drilldown" : "E. Choroba" - }, - { - "y" : 4, - "name" : "Mark Anderson", - "drilldown" : "Mark Anderson" - }, - { - "y" : 2, - "name" : "Niels van Dijke", - "drilldown" : "Niels van Dijke" - }, - { - "name" : "Packy Anderson", - "drilldown" : "Packy Anderson", - "y" : 5 - }, - { - "y" : 2, - "drilldown" : "Peter Meszaros", - "name" : "Peter Meszaros" - }, - { - "y" : 3, - "drilldown" : "Robbie Hatley", - "name" : "Robbie Hatley" - }, - { - "drilldown" : "Stephen G. Lynn", - "name" : "Stephen G. Lynn", - "y" : 3 - }, - { - "y" : 4, - "drilldown" : "Thomas Kohler", - "name" : "Thomas Kohler" - }, - { - "name" : "W. Luis Mochan", - "drilldown" : "W. Luis Mochan", - "y" : 3 - } - ] - } - ], "drilldown" : { "series" : [ { + "id" : "Ali Moradi", + "name" : "Ali Moradi", "data" : [ [ "Perl", @@ -97,19 +28,31 @@ "Blog", 1 ] + ] + }, + { + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] ], - "id" : "Ali Moradi", - "name" : "Ali Moradi" + "name" : "Arne Sommer", + "id" : "Arne Sommer" }, { "name" : "Bob Lied", + "id" : "Bob Lied", "data" : [ [ "Perl", 2 ] - ], - "id" : "Bob Lied" + ] }, { "data" : [ @@ -126,26 +69,40 @@ "name" : "Dave Jacoby" }, { + "id" : "David Ferrone", + "name" : "David Ferrone", "data" : [ [ "Perl", 2 ] - ], - "id" : "David Ferrone", - "name" : "David Ferrone" + ] }, { - "name" : "E. Choroba", "data" : [ [ "Perl", 2 ] ], + "name" : "E. Choroba", "id" : "E. Choroba" }, { + "id" : "Luca Ferrari", + "name" : "Luca Ferrari", + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 8 + ] + ] + }, + { "data" : [ [ "Raku", @@ -156,18 +113,28 @@ 2 ] ], - "id" : "Mark Anderson", - "name" : "Mark Anderson" + "name" : "Mark Anderson", + "id" : "Mark Anderson" + }, + { + "name" : "Matthew Neleigh", + "id" : "Matthew Neleigh", + "data" : [ + [ + "Perl", + 2 + ] + ] }, { - "name" : "Niels van Dijke", "data" : [ [ "Perl", 2 ] ], - "id" : "Niels van Dijke" + "id" : "Niels van Dijke", + "name" : "Niels van Dijke" }, { "data" : [ @@ -188,13 +155,27 @@ "name" : "Packy Anderson" }, { - "name" : "Peter Meszaros", + "name" : "Peter Campbell Smith", + "id" : "Peter Campbell Smith", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { "data" : [ [ "Perl", 2 ] ], + "name" : "Peter Meszaros", "id" : "Peter Meszaros" }, { @@ -212,6 +193,30 @@ ] }, { + "id" : "Roger Bell_West", + "name" : "Roger Bell_West", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ] + }, + { + "data" : [ + [ + "Raku", + 2 + ] + ], + "id" : "Simon Proctor", + "name" : "Simon Proctor" + }, + { "data" : [ [ "Perl", @@ -226,7 +231,6 @@ "name" : "Stephen G. Lynn" }, { - "id" : "Thomas Kohler", "data" : [ [ "Perl", @@ -237,7 +241,22 @@ 2 ] ], - "name" : "Thomas Kohler" + "name" : "Thomas Kohler", + "id" : "Thomas Kohler" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ], + "id" : "Ulrich Rieke", + "name" : "Ulrich Rieke" }, { "data" : [ @@ -250,28 +269,128 @@ 1 ] ], - "id" : "W. Luis Mochan", - "name" : "W. Luis Mochan" + "name" : "W. Luis Mochan", + "id" : "W. Luis Mochan" } ] }, "plotOptions" : { "series" : { + "borderWidth" : 0, "dataLabels" : { "format" : "{point.y}", "enabled" : 1 - }, - "borderWidth" : 0 + } } }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" + "series" : [ + { + "name" : "The Weekly Challenge - 250", + "colorByPoint" : 1, + "data" : [ + { + "y" : 5, + "name" : "Ali Moradi", + "drilldown" : "Ali Moradi" + }, + { + "drilldown" : "Arne Sommer", + "y" : 3, + "name" : "Arne Sommer" + }, + { + "y" : 2, + "name" : "Bob Lied", + "drilldown" : "Bob Lied" + }, + { + "y" : 3, + "name" : "Dave Jacoby", + "drilldown" : "Dave Jacoby" + }, + { + "y" : 2, + "name" : "David Ferrone", + "drilldown" : "David Ferrone" + }, + { + "drilldown" : "E. Choroba", + "y" : 2, + "name" : "E. Choroba" + }, + { + "name" : "Luca Ferrari", + "y" : 10, + "drilldown" : "Luca Ferrari" + }, + { + "y" : 4, + "name" : "Mark Anderson", + "drilldown" : "Mark Anderson" + }, + { + "drilldown" : "Matthew Neleigh", + "name" : "Matthew Neleigh", + "y" : 2 + }, + { + "drilldown" : "Niels van Dijke", + "y" : 2, + "name" : "Niels van Dijke" + }, + { + "drilldown" : "Packy Anderson", + "name" : "Packy Anderson", + "y" : 5 + }, + { + "y" : 3, + "name" : "Peter Campbell Smith", + "drilldown" : "Peter Campbell Smith" + }, + { + "drilldown" : "Peter Meszaros", + "y" : 2, + "name" : "Peter Meszaros" + }, + { + "drilldown" : "Robbie Hatley", + "name" : "Robbie Hatley", + "y" : 3 + }, + { + "name" : "Roger Bell_West", + "y" : 4, + "drilldown" : "Roger Bell_West" + }, + { + "drilldown" : "Simon Proctor", + "y" : 2, + "name" : "Simon Proctor" + }, + { + "name" : "Stephen G. Lynn", + "y" : 3, + "drilldown" : "Stephen G. Lynn" + }, + { + "name" : "Thomas Kohler", + "y" : 4, + "drilldown" : "Thomas Kohler" + }, + { + "drilldown" : "Ulrich Rieke", + "name" : "Ulrich Rieke", + "y" : 4 + }, + { + "drilldown" : "W. Luis Mochan", + "y" : 3, + "name" : "W. Luis Mochan" + } + ] } - }, - "title" : { - "text" : "The Weekly Challenge - 250" - }, + ], "legend" : { "enabled" : 0 }, @@ -279,5 +398,11 @@ "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", "followPointer" : 1 + }, + "xAxis" : { + "type" : "category" + }, + "chart" : { + "type" : "column" } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index daaea91452..1cfcf1a068 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,63 +1,63 @@ { - "subtitle" : { - "text" : "Last updated at 2024-01-02 12:36:13 GMT" + "yAxis" : { + "title" : { + "text" : null + }, + "min" : 0 }, - "chart" : { - "type" : "column" + "subtitle" : { + "text" : "Last updated at 2024-01-04 15:50:20 GMT" }, - "xAxis" : { - "labels" : { - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - } - }, - "type" : "category" + "title" : { + "text" : "The Weekly Challenge Contributions [2019 - 2024]" }, "series" : [ { "dataLabels" : { "format" : "{point.y:.0f}", "enabled" : "true", - "color" : "#FFFFFF", - "rotation" : -90, "align" : "right", "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" }, + "rotation" : -90, + "color" : "#FFFFFF", "y" : 10 }, - "name" : "Contributions", "data" : [ [ "Blog", - 4362 + 4372 ], [ "Perl", - 12875 + 12883 ], [ "Raku", - 7414 + 7424 ] - ] + ], + "name" : "Contributions" } ], - "yAxis" : { - "title" : { - "text" : null - }, - "min" : 0 - }, - "title" : { - "text" : "The Weekly Challenge Contributions [2019 - 2024]" + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" }, "legend" : { "enabled" : "false" }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" + "xAxis" : { + "type" : "category", + "labels" : { + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + } + } + }, + "chart" : { + "type" : "column" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 549bdff888..8f45fee707 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,1285 +1,17 @@ { - "tooltip" : { - "followPointer" : "true", - "headerFormat" : "<span style=\"font-size:11px\"></span>", - "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>" - }, - "legend" : { - "enabled" : "false" - }, - "title" : { - "text" : "The Weekly Challenge Language" - }, - "series" : [ - { - "name" : "The Weekly Challenge Languages", - "colorByPoint" : "true", - "data" : [ - { - "y" : 164, - "name" : "#001", - "drilldown" : "001" - }, - { - "y" : 129, - "drilldown" : "002", - "name" : "#002" - }, - { - "y" : 87, - "name" : "#003", - "drilldown" : "003" - }, - { - "drilldown" : "004", - "name" : "#004", - "y" : 103 - }, - { - "y" : 80, - "drilldown" : "005", - "name" : "#005" - }, - { - "y" : 61, - "name" : "#006", - "drilldown" : "006" - }, - { - "y" : 69, - "name" : "#007", - "drilldown" : "007" - }, - { - "y" : 82, - "drilldown" : "008", - "name" : "#008" - }, - { - "y" : 80, - "drilldown" : "009", - "name" : "#009" - }, - { - "y" : 69, - "name" : "#010", - "drilldown" : "010" - }, - { - "name" : "#011", - "drilldown" : "011", - "y" : 89 - }, - { - "drilldown" : "012", - "name" : "#012", - "y" : 92 - }, - { - "y" : 87, - |
