diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-07-28 11:42:20 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-07-28 11:42:20 +0100 |
| commit | d5ce09a67599e62df79105bfe5d87dffe59bb083 (patch) | |
| tree | 398ccb152f10cbbcc05f9d608ffece41aa93e8f2 | |
| parent | 4a031b46851124e11e9b4c55e4b8c5c1289b5607 (diff) | |
| download | perlweeklychallenge-club-d5ce09a67599e62df79105bfe5d87dffe59bb083.tar.gz perlweeklychallenge-club-d5ce09a67599e62df79105bfe5d87dffe59bb083.tar.bz2 perlweeklychallenge-club-d5ce09a67599e62df79105bfe5d87dffe59bb083.zip | |
- Added solutions by Packy Anderson.
- Added solutions by Robert Ransbottom.
24 files changed, 2698 insertions, 2563 deletions
diff --git a/challenge-226/packy-anderson/blog.txt b/challenge-226/packy-anderson/blog.txt new file mode 100644 index 0000000000..6e4ebbe942 --- /dev/null +++ b/challenge-226/packy-anderson/blog.txt @@ -0,0 +1 @@ +http://packy.dardan.com/2023/07/26/perl-weekly-challenge-226/ diff --git a/challenge-226/ulrich-rieke/cpp/ch-1.cpp b/challenge-226/ulrich-rieke/cpp/ch-1.cpp new file mode 100755 index 0000000000..6b0c8c12bb --- /dev/null +++ b/challenge-226/ulrich-rieke/cpp/ch-1.cpp @@ -0,0 +1,43 @@ +#include <iostream>
+#include <string>
+#include <vector>
+#include <utility>
+#include <algorithm>
+
+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 a string!\n" ;
+ std::string str ;
+ std::getline( std::cin , str ) ;
+ std::cout << "Enter indices into the string!\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<std::pair<int, char>> allPairs ;
+ for ( int i = 0 ; i < numberstrings.size( ) ; i++ ) {
+ allPairs.push_back( std::make_pair( numbers[ i ] , str[ i ] ) ) ;
+ }
+ std::sort( allPairs.begin( ) , allPairs.end( ) , []( const auto & p1 ,
+ const auto & p2 ) { return p1.first < p2.first ; } ) ;
+ std::string solution ;
+ for ( const auto p : allPairs )
+ solution += p.second ;
+ std::cout << solution << std::endl ;
+ return 0 ;
+}
+
diff --git a/challenge-226/ulrich-rieke/cpp/ch-2.cpp b/challenge-226/ulrich-rieke/cpp/ch-2.cpp new file mode 100755 index 0000000000..d80e8da2a5 --- /dev/null +++ b/challenge-226/ulrich-rieke/cpp/ch-2.cpp @@ -0,0 +1,48 @@ +#include <iostream>
+#include <string>
+#include <vector>
+#include <algorithm>
+
+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 mySubtr( int n , int min ) {
+ n -= min ;
+ if ( n < 0 )
+ n = 0 ;
+ return n ;
+}
+
+int main( ) {
+ std::cout << "Enter some positive 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 ) ) ;
+ }
+ int rounds = 0 ;
+ while ( ! std::all_of( numbers.begin( ) , numbers.end( ) , []( int n ) {
+ return n == 0 ; } ) ) {
+ std::vector<int> positives ;
+ std::copy_if( numbers.begin( ) , numbers.end( ) , std::back_inserter(
+ positives ) , []( int i ) { return i > 0 ; } ) ;
+ int mini = *std::min_element( positives.begin( ) , positives.end( ) ) ;
+ rounds++ ;
+ std::transform( numbers.begin( ) , numbers.end( ) , numbers.begin( ) ,
+ [mini]( int i ) { return mySubtr( i , mini ) ; } ) ;
+ }
+ std::cout << rounds << std::endl ;
+ return 0 ;
+}
diff --git a/challenge-227/packy-anderson/blog.txt b/challenge-227/packy-anderson/blog.txt new file mode 100644 index 0000000000..937edace41 --- /dev/null +++ b/challenge-227/packy-anderson/blog.txt @@ -0,0 +1 @@ +http://packy.dardan.com/2023/07/27/perl-weekly-challenge-227/ diff --git a/challenge-227/packy-anderson/perl/task-1.pl b/challenge-227/packy-anderson/perl/ch-1.pl index 1bfd2a1d13..1bfd2a1d13 100755 --- a/challenge-227/packy-anderson/perl/task-1.pl +++ b/challenge-227/packy-anderson/perl/ch-1.pl diff --git a/challenge-227/packy-anderson/perl/task-2.pl b/challenge-227/packy-anderson/perl/ch-2.pl index 425a4341ea..425a4341ea 100755 --- a/challenge-227/packy-anderson/perl/task-2.pl +++ b/challenge-227/packy-anderson/perl/ch-2.pl diff --git a/challenge-227/packy-anderson/raku/task-1.raku b/challenge-227/packy-anderson/raku/ch-1.raku index d9fef52c0d..d9fef52c0d 100755 --- a/challenge-227/packy-anderson/raku/task-1.raku +++ b/challenge-227/packy-anderson/raku/ch-1.raku diff --git a/challenge-227/packy-anderson/raku/task-2.raku b/challenge-227/packy-anderson/raku/ch-2.raku index 252340956f..252340956f 100755 --- a/challenge-227/packy-anderson/raku/task-2.raku +++ b/challenge-227/packy-anderson/raku/ch-2.raku diff --git a/stats/pwc-challenge-226.json b/stats/pwc-challenge-226.json index f91238b23a..a72d032522 100644 --- a/stats/pwc-challenge-226.json +++ b/stats/pwc-challenge-226.json @@ -1,41 +1,50 @@ { - "xAxis" : { - "type" : "category" + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + } + } }, - "subtitle" : { - "text" : "[Champions: 36] Last updated at 2023-07-25 23:36:03 GMT" + "legend" : { + "enabled" : 0 }, - "chart" : { - "type" : "column" + "tooltip" : { + "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/>", + "followPointer" : 1 }, "series" : [ { + "colorByPoint" : 1, "name" : "The Weekly Challenge - 226", "data" : [ { + "drilldown" : "Adam Russell", "name" : "Adam Russell", - "y" : 4, - "drilldown" : "Adam Russell" + "y" : 4 }, { - "drilldown" : "Adriaan Dens", "y" : 2, - "name" : "Adriaan Dens" + "name" : "Adriaan Dens", + "drilldown" : "Adriaan Dens" }, { - "name" : "Ali Moradi", "y" : 4, + "name" : "Ali Moradi", "drilldown" : "Ali Moradi" }, { - "drilldown" : "Andreas Voegele", + "y" : 2, "name" : "Andreas Voegele", - "y" : 2 + "drilldown" : "Andreas Voegele" }, { - "y" : 3, + "drilldown" : "Arne Sommer", "name" : "Arne Sommer", - "drilldown" : "Arne Sommer" + "y" : 3 }, { "name" : "Athanasius", @@ -44,8 +53,8 @@ }, { "drilldown" : "Avery Adams", - "y" : 1, - "name" : "Avery Adams" + "name" : "Avery Adams", + "y" : 1 }, { "y" : 4, @@ -53,19 +62,19 @@ "drilldown" : "BarrOff" }, { - "y" : 3, + "drilldown" : "Bob Lied", "name" : "Bob Lied", - "drilldown" : "Bob Lied" + "y" : 3 }, { "drilldown" : "Bruce Gray", - "y" : 2, - "name" : "Bruce Gray" + "name" : "Bruce Gray", + "y" : 2 }, { + "drilldown" : "Cheok-Yin Fung", "y" : 2, - "name" : "Cheok-Yin Fung", - "drilldown" : "Cheok-Yin Fung" + "name" : "Cheok-Yin Fung" }, { "drilldown" : "Dave Jacoby", @@ -73,14 +82,14 @@ "y" : 3 }, { - "drilldown" : "David Ferrone", "y" : 2, - "name" : "David Ferrone" + "name" : "David Ferrone", + "drilldown" : "David Ferrone" }, { "drilldown" : "E. Choroba", - "name" : "E. Choroba", - "y" : 2 + "y" : 2, + "name" : "E. Choroba" }, { "drilldown" : "Flavio Poletti", @@ -88,14 +97,14 @@ "y" : 6 }, { + "drilldown" : "Jaldhar H. Vyas", "name" : "Jaldhar H. Vyas", - "y" : 5, - "drilldown" : "Jaldhar H. Vyas" + "y" : 5 }, { "drilldown" : "Jan Krnavek", - "name" : "Jan Krnavek", - "y" : 2 + "y" : 2, + "name" : "Jan Krnavek" }, { "drilldown" : "Jorg Sommrey", @@ -103,113 +112,112 @@ "name" : "Jorg Sommrey" }, { - "drilldown" : "Laurent Rosenfeld", + "y" : 6, "name" : "Laurent Rosenfeld", - "y" : 6 + "drilldown" : "Laurent Rosenfeld" }, { - "drilldown" : "Lubos Kolouch", + "name" : "Lubos Kolouch", "y" : 2, - "name" : "Lubos Kolouch" + "drilldown" : "Lubos Kolouch" }, { + "drilldown" : "Luca Ferrari", "name" : "Luca Ferrari", - "y" : 8, - "drilldown" : "Luca Ferrari" + "y" : 8 }, { - "drilldown" : "Mark Anderson", "y" : 2, - "name" : "Mark Anderson" + "name" : "Mark Anderson", + "drilldown" : "Mark Anderson" }, { - "drilldown" : "Matthew Neleigh", + "name" : "Matthew Neleigh", "y" : 2, - "name" : "Matthew Neleigh" + "drilldown" : "Matthew Neleigh" }, { "drilldown" : "Niels van Dijke", - "name" : "Niels van Dijke", - "y" : 2 + "y" : 2, + "name" : "Niels van Dijke" }, { "drilldown" : "Packy Anderson", - "y" : 4, - "name" : "Packy Anderson" + "name" : "Packy Anderson", + "y" : 5 }, { - "drilldown" : "Peter Campbell Smith", "name" : "Peter Campbell Smith", - "y" : 3 + "y" : 3, + "drilldown" : "Peter Campbell Smith" }, { + "drilldown" : "PokGoPun", "name" : "PokGoPun", - "y" : 2, - "drilldown" : "PokGoPun" + "y" : 2 }, { - "drilldown" : "Robbie Hatley", + "y" : 3, "name" : "Robbie Hatley", - "y" : 3 + "drilldown" : "Robbie Hatley" }, { - "drilldown" : "Robert DiCicco", + "name" : "Robert DiCicco", "y" : 4, - "name" : "Robert DiCicco" + "drilldown" : "Robert DiCicco" }, { - "drilldown" : "Robert Ransbottom", "y" : 2, - "name" : "Robert Ransbottom" + "name" : "Robert Ransbottom", + "drilldown" : "Robert Ransbottom" }, { - "name" : "Roger Bell_West", "y" : 5, + "name" : "Roger Bell_West", "drilldown" : "Roger Bell_West" }, { - "drilldown" : "Simon Green", "y" : 3, - "name" : "Simon Green" + "name" : "Simon Green", + "drilldown" : "Simon Green" }, { - "y" : 2, + "drilldown" : "Steven Wilson", "name" : "Steven Wilson", - "drilldown" : "Steven Wilson" + "y" : 2 }, { + "drilldown" : "Thomas Kohler", "name" : "Thomas Kohler", - "y" : 4, - "drilldown" : "Thomas Kohler" + "y" : 4 }, { "drilldown" : "Ulrich Rieke", - "name" : "Ulrich Rieke", - "y" : 4 + "y" : 4, + "name" : "Ulrich Rieke" }, { "drilldown" : "W. Luis Mochan", "name" : "W. Luis Mochan", "y" : 3 } - ], - "colorByPoint" : 1 + ] } ], "title" : { "text" : "The Weekly Challenge - 226" }, - "legend" : { - "enabled" : 0 + "chart" : { + "type" : "column" }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } + "subtitle" : { + "text" : "[Champions: 36] Last updated at 2023-07-28 10:14:26 GMT" }, "drilldown" : { "series" : [ { + "id" : "Adam Russell", + "name" : "Adam Russell", "data" : [ [ "Perl", @@ -219,23 +227,19 @@ "Blog", 2 ] - ], - "id" : "Adam Russell", - "name" : "Adam Russell" + ] }, { "name" : "Adriaan Dens", + "id" : "Adriaan Dens", "data" : [ [ "Perl", 2 ] - ], - "id" : "Adriaan Dens" + ] }, { - "name" : "Ali Moradi", - "id" : "Ali Moradi", "data" : [ [ "Perl", @@ -245,7 +249,9 @@ "Raku", 2 ] - ] + ], + "id" : "Ali Moradi", + "name" : "Ali Moradi" }, { "data" : [ @@ -254,11 +260,10 @@ 2 ] ], - "id" : "Andreas Voegele", - "name" : "Andreas Voegele" + "name" : "Andreas Voegele", + "id" : "Andreas Voegele" }, { - "name" : "Arne Sommer", "data" : [ [ "Raku", @@ -269,11 +274,12 @@ 1 ] ], + "name" : "Arne Sommer", "id" : "Arne Sommer" }, { - "name" : "Athanasius", "id" : "Athanasius", + "name" : "Athanasius", "data" : [ [ "Perl", @@ -286,14 +292,14 @@ ] }, { - "name" : "Avery Adams", - "id" : "Avery Adams", "data" : [ [ "Perl", 1 ] - ] + ], + "id" : "Avery Adams", + "name" : "Avery Adams" }, { "name" : "BarrOff", @@ -310,8 +316,6 @@ ] }, { - "name" : "Bob Lied", - "id" : "Bob Lied", "data" : [ [ "Perl", @@ -321,31 +325,31 @@ "Blog", 1 ] - ] + ], + "name" : "Bob Lied", + "id" : "Bob Lied" }, { - "name" : "Bruce Gray", "data" : [ [ "Raku", 2 ] ], - "id" : "Bruce Gray" + "id" : "Bruce Gray", + "name" : "Bruce Gray" }, { + "id" : "Cheok-Yin Fung", + "name" : "Cheok-Yin Fung", "data" : [ [ "Perl", 2 ] - ], - "id" : "Cheok-Yin Fung", - "name" : "Cheok-Yin Fung" + ] }, { - "name" : "Dave Jacoby", - "id" : "Dave Jacoby", "data" : [ [ "Perl", @@ -355,31 +359,31 @@ "Blog", 1 ] - ] + ], + "name" : "Dave Jacoby", + "id" : "Dave Jacoby" }, { - "name" : "David Ferrone", - "id" : "David Ferrone", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "David Ferrone", + "id" : "David Ferrone" }, { "name" : "E. Choroba", + "id" : "E. Choroba", "data" : [ [ "Perl", 2 ] - ], - "id" : "E. Choroba" + ] }, { - "name" : "Flavio Poletti", - "id" : "Flavio Poletti", "data" : [ [ "Perl", @@ -393,7 +397,9 @@ "Blog", 2 ] - ] + ], + "name" : "Flavio Poletti", + "id" : "Flavio Poletti" }, { "data" : [ @@ -414,27 +420,28 @@ "name" : "Jaldhar H. Vyas" }, { + "id" : "Jan Krnavek", + "name" : "Jan Krnavek", "data" : [ [ "Raku", 2 ] - ], - "id" : "Jan Krnavek", - "name" : "Jan Krnavek" + ] }, { - "id" : "Jorg Sommrey", "data" : [ [ "Perl", 2 ] ], - "name" : "Jorg Sommrey" + "name" : "Jorg Sommrey", + "id" : "Jorg Sommrey" }, { "name" : "Laurent Rosenfeld", + "id" : "Laurent Rosenfeld", "data" : [ [ "Perl", @@ -448,22 +455,19 @@ "Blog", 2 ] - ], - "id" : "Laurent Rosenfeld" + ] }, { + "id" : "Lubos Kolouch", + "name" : "Lubos Kolouch", "data" : [ [ "Perl", 2 ] - ], - "id" : "Lubos Kolouch", - "name" : "Lubos Kolouch" + ] }, { - "name" : "Luca Ferrari", - "id" : "Luca Ferrari", "data" : [ [ "Raku", @@ -473,11 +477,13 @@ "Blog", 6 ] - ] + ], + "name" : "Luca Ferrari", + "id" : "Luca Ferrari" }, { - "name" : "Mark Anderson", "id" : "Mark Anderson", + "name" : "Mark Anderson", "data" : [ [ "Raku", @@ -487,26 +493,25 @@ }, { "id" : "Matthew Neleigh", + "name" : "Matthew Neleigh", "data" : [ [ "Perl", 2 ] - ], - "name" : "Matthew Neleigh" + ] }, { - "name" : "Niels van Dijke", "data" : [ [ "Perl", 2 ] ], + "name" : "Niels van Dijke", "id" : "Niels van Dijke" }, { - "id" : "Packy Anderson", "data" : [ [ "Perl", @@ -515,11 +520,18 @@ [ "Raku", 2 + ], + [ + "Blog", + 1 ] ], - "name" : "Packy Anderson" + "name" : "Packy Anderson", + "id" : "Packy Anderson" }, { + "id" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith", "data" : [ [ "Perl", @@ -529,22 +541,21 @@ "Blog", 1 ] - ], - "id" : "Peter Campbell Smith", - "name" : "Peter Campbell Smith" + ] }, { + "name" : "PokGoPun", "id" : "PokGoPun", "data" : [ [ "Perl", 2 ] - ], - "name" : "PokGoPun" + ] }, { "id" : "Robbie Hatley", + "name" : "Robbie Hatley", "data" : [ [ "Perl", @@ -554,12 +565,11 @@ "Blog", 1 ] - ], - "name" : "Robbie Hatley" + ] }, { - "name" : "Robert DiCicco", "id" : "Robert DiCicco", + "name" : "Robert DiCicco", "data" : [ [ "Perl", @@ -572,17 +582,16 @@ ] }, { - "name" : "Robert Ransbottom", - "id" : "Robert Ransbottom", "data" : [ [ "Raku", 2 ] - ] + ], + "name" : "Robert Ransbottom", + "id" : "Robert Ransbottom" }, { - "id" : "Roger Bell_West", "data" : [ [ "Perl", @@ -597,6 +606,7 @@ 1 ] ], + "id" : "Roger Bell_West", "name" : "Roger Bell_West" }, { @@ -610,18 +620,18 @@ 1 ] ], - "id" : "Simon Green", - "name" : "Simon Green" + "name" : "Simon Green", + "id" : "Simon Green" }, { + "name" : "Steven Wilson", "id" : "Steven Wilson", "data" : [ [ "Perl", 2 ] - ], - "name" : "Steven Wilson" + ] }, { "data" : [ @@ -634,8 +644,8 @@ 2 ] ], - "id" : "Thomas Kohler", - "name" : "Thomas Kohler" + "name" : "Thomas Kohler", + "id" : "Thomas Kohler" }, { "data" : [ @@ -648,11 +658,12 @@ 2 ] ], - "id" : "Ulrich Rieke", - "name" : "Ulrich Rieke" + "name" : "Ulrich Rieke", + "id" : "Ulrich Rieke" }, { "name" : "W. Luis Mochan", + "id" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -662,23 +673,16 @@ "Blog", 1 ] - ], - "id" : "W. Luis Mochan" + ] } ] }, - "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/>" - }, - "plotOptions" : { - "series" : { - "borderWidth" : 0, - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - } + "yAxis" : { + "title" : { + "text" : "Total Solutions" } + }, + "xAxis" : { + "type" : "category" } } diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 2651e7b38d..5991823390 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,8 +1,145 @@ { + "xAxis" : { + "type" : "category" + }, + "title" : { + "text" : "The Weekly Challenge - 227" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "series" : [ + { + "data" : [ + { + "name" : "Ali Moradi", + "y" : 3, + "drilldown" : "Ali Moradi" + }, + { + "drilldown" : "Andrew Shitov", + "y" : 4, + "name" : "Andrew Shitov" + }, + { + "drilldown" : "Arne Sommer", + "name |
