diff options
22 files changed, 1620 insertions, 1435 deletions
diff --git a/challenge-171/ulrich-rieke/cpp/ch-1.cpp b/challenge-171/ulrich-rieke/cpp/ch-1.cpp new file mode 100644 index 0000000000..64182ec9a4 --- /dev/null +++ b/challenge-171/ulrich-rieke/cpp/ch-1.cpp @@ -0,0 +1,32 @@ +#include <iostream> +#include <vector> +#include <numeric> + +std::vector<int> findDivisors( int n ) { + std::vector<int> divisors ; + for ( int i = 1 ; i < (n / 2 ) + 1 ; i++ ) { + if ( n % i == 0 ) + divisors.push_back( i ) ; + } + return divisors ; +} + +bool isAbundant( int n ) { + std::vector<int> divisors = findDivisors( n ) ; + int sum = std::accumulate( divisors.begin( ) , divisors.end( ) , 0 ) ; + return sum > n ; +} + +int main( ) { + std::vector<int> oddAbundant ; + int current = 3 ; + while ( oddAbundant.size( ) != 20 ) { + if ( isAbundant( current ) ) + oddAbundant.push_back( current ) ; + current += 2 ; + } + for ( int n : oddAbundant ) + std::cout << n << ' ' ; + std::cout << std::endl ; + return 0 ; +} diff --git a/challenge-171/ulrich-rieke/cpp/ch-2.cpp b/challenge-171/ulrich-rieke/cpp/ch-2.cpp new file mode 100644 index 0000000000..d7bdcc363e --- /dev/null +++ b/challenge-171/ulrich-rieke/cpp/ch-2.cpp @@ -0,0 +1,19 @@ +#include <iostream> +#include <cmath> + +int func1( int n ) { + return 5 * n ; +} + +double func2 ( int m ) { + return std::sqrt( static_cast<double>( m ) ) ; +} + +double compose( int n ) { + return func2( func1( n ) ) ; +} + +int main( ) { + std::cout << compose( 6 ) << '\n' ; + return 0 ; +} diff --git a/challenge-171/ulrich-rieke/haskell/ch-1.hs b/challenge-171/ulrich-rieke/haskell/ch-1.hs new file mode 100644 index 0000000000..e2a71e3650 --- /dev/null +++ b/challenge-171/ulrich-rieke/haskell/ch-1.hs @@ -0,0 +1,11 @@ +module Challenge171 + where + +findDivisors :: Int -> [Int] +findDivisors n = [d | d <- [1 .. div n 2] , mod n d == 0] + +isAbundant :: Int -> Bool +isAbundant n = (sum $ findDivisors n) > n + +solution :: [Int] +solution = take 20 $ filter isAbundant $ enumFromThen 3 5 diff --git a/challenge-171/ulrich-rieke/haskell/ch-2.hs b/challenge-171/ulrich-rieke/haskell/ch-2.hs new file mode 100644 index 0000000000..2f8561699e --- /dev/null +++ b/challenge-171/ulrich-rieke/haskell/ch-2.hs @@ -0,0 +1,11 @@ +module Challenge171_2 + where + +func1 :: Int -> Int +func1 = ( * 5 ) + +func2 :: Int -> Double +func2 = sqrt . fromIntegral + +compose :: Int -> Double +compose = func2 . func1 diff --git a/challenge-171/ulrich-rieke/perl/ch-1.pl b/challenge-171/ulrich-rieke/perl/ch-1.pl new file mode 100644 index 0000000000..2c6aa9938e --- /dev/null +++ b/challenge-171/ulrich-rieke/perl/ch-1.pl @@ -0,0 +1,32 @@ +#!/usr/bin/perl ; +use strict ; +use warnings ; +use feature 'say' ; +use List::Util qw ( sum ) ; + +sub findDivisors { + my $number = shift ; + my @divisors ; + for my $i ( 1 .. int( $number / 2 ) ) { + if ( $number % $i == 0 ) { + push @divisors , $i ; + } + } + return @divisors ; +} + +sub isAbundant { + my $number = shift ; + my @divisors = findDivisors( $number ) ; + return sum( @divisors ) > $number ; +} + +my @oddAbundant ; +my $current = 3 ; +while ( scalar( @oddAbundant ) != 20 ) { + if ( isAbundant( $current ) ) { + push @oddAbundant , $current ; + } + $current += 2 ; +} +say join( ',' , @oddAbundant ) ; diff --git a/challenge-171/ulrich-rieke/perl/ch-2.pl b/challenge-171/ulrich-rieke/perl/ch-2.pl new file mode 100644 index 0000000000..cd179bb4f8 --- /dev/null +++ b/challenge-171/ulrich-rieke/perl/ch-2.pl @@ -0,0 +1,25 @@ +#!/usr/bin/perl ; +use strict ; +use warnings ; +use feature 'say' ; + +my $f = sub { + my $num1 = shift ; + return 5 * $num1 ; +} ; + +my $g = sub { + my $num2 = shift ; + return sqrt( $num2 ) ; +} ; + +sub compose { + my ( $func1 , $func2 ) = @_ ; + return sub { + my $num = shift ; + &$func2( &$func1( $num ) ) ; + } +} + +my $h = &compose( $f , $g ) ; +say $h->(6) ; diff --git a/challenge-171/ulrich-rieke/raku/ch-1.raku b/challenge-171/ulrich-rieke/raku/ch-1.raku new file mode 100644 index 0000000000..a92456c40c --- /dev/null +++ b/challenge-171/ulrich-rieke/raku/ch-1.raku @@ -0,0 +1,26 @@ +use v6 ; + +sub findDivisors( Int $n ) { + my @divisors ; + for ( 1 .. $n div 2 ) -> $i { + if ( $n %% $i ) { + @divisors.push( $i ) ; + } + } + return @divisors ; +} + +sub isAbundant( Int $n ) { + my @divisors = findDivisors( $n ) ; + return ([+] @divisors) > $n ; +} + +my @oddAbundants ; +my $current = 3 ; #start at 3 because 1 is not a proper divisor of 1 +while ( @oddAbundants.elems != 20 ) { + if ( isAbundant( $current ) ) { + @oddAbundants.push( $current ) ; + } + $current += 2 ; +} +say join( ',' , @oddAbundants ) ; diff --git a/challenge-171/ulrich-rieke/raku/ch-2.raku b/challenge-171/ulrich-rieke/raku/ch-2.raku new file mode 100644 index 0000000000..d8e65b2ff4 --- /dev/null +++ b/challenge-171/ulrich-rieke/raku/ch-2.raku @@ -0,0 +1,10 @@ +use v6 ; + +my $f = sub ( Int $m ) { 5 * $m } ; +my $g = sub ( Int $n ) { sqrt( $n ) } ; + +sub compose( $firstFunc , $secondFunc ) { return sub ( Int $x ) { + $secondFunc( $firstFunc($x ) ) }} ; + +my $h = compose( $f , $g ) ; +say $h( 6 ) ; diff --git a/stats/pwc-current.json b/stats/pwc-current.json index f154d78d73..0a923b381d 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,27 +1,22 @@ { - "plotOptions" : { - "series" : { - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - }, - "borderWidth" : 0 - } + "chart" : { + "type" : "column" }, "drilldown" : { "series" : [ { + "id" : "Ali Moradi", "name" : "Ali Moradi", "data" : [ [ "Perl", 2 ] - ], - "id" : "Ali Moradi" + ] }, { "id" : "Bartosz Jarzyna", + "name" : "Bartosz Jarzyna", "data" : [ [ "Perl", @@ -31,27 +26,26 @@ "Raku", 1 ] - ], - "name" : "Bartosz Jarzyna" + ] }, { - "name" : "Dario Mazzeo", "data" : [ [ "Perl", 1 ] ], - "id" : "Dario Mazzeo" + "id" : "Dario Mazzeo", + "name" : "Dario Mazzeo" }, { - "id" : "Dave Jacoby", "data" : [ [ "Perl", 2 ] ], + "id" : "Dave Jacoby", "name" : "Dave Jacoby" }, { @@ -61,22 +55,20 @@ 2 ] ], - "id" : "E. Choroba", - "name" : "E. Choroba" + "name" : "E. Choroba", + "id" : "E. Choroba" }, { - "name" : "Humberto Massa", "data" : [ [ "Raku", 2 ] ], + "name" : "Humberto Massa", "id" : "Humberto Massa" }, { - "name" : "James Smith", - "id" : "James Smith", "data" : [ [ "Perl", @@ -86,17 +78,19 @@ "Blog", 1 ] - ] + ], + "id" : "James Smith", + "name" : "James Smith" }, { - "id" : "Kjetil Skotheim", "data" : [ [ "Perl", 2 ] ], - "name" : "Kjetil Skotheim" + "name" : "Kjetil Skotheim", + "id" : "Kjetil Skotheim" }, { "name" : "Laurent Rosenfeld", @@ -131,48 +125,46 @@ "name" : "Luca Ferrari" }, { + "id" : "Marton Polgar", + "name" : "Marton Polgar", "data" : [ [ "Raku", 2 ] - ], - "id" : "Marton Polgar", - "name" : "Marton Polgar" + ] }, { + "name" : "Matthew Neleigh", "id" : "Matthew Neleigh", "data" : [ [ "Perl", 2 ] - ], - "name" : "Matthew Neleigh" + ] }, { + "id" : "Mohammad S Anwar", + "name" : "Mohammad S Anwar", "data" : [ [ "Perl", 2 ] - ], - "id" : "Mohammad S Anwar", - "name" : "Mohammad S Anwar" + ] }, { + "id" : "Philippe Bricout", "name" : "Philippe Bricout", "data" : [ [ "Perl", 1 ] - ], - "id" : "Philippe Bricout" + ] }, { - "name" : "Robert DiCicco", - "id" : "Robert DiCicco", "data" : [ [ "Perl", @@ -182,20 +174,21 @@ "Raku", 1 ] - ] + ], + "id" : "Robert DiCicco", + "name" : "Robert DiCicco" }, { + "id" : "Robert Ransbottom", "name" : "Robert Ransbottom", "data" : [ [ "Raku", 2 ] - ], - "id" : "Robert Ransbottom" + ] }, { - "name" : "Roger Bell_West", "data" : [ [ "Perl", @@ -206,10 +199,12 @@ 2 ] ], + "name" : "Roger Bell_West", "id" : "Roger Bell_West" }, { "name" : "Stephen G Lynn", + "id" : "Stephen G Lynn", "data" : [ [ "Perl", @@ -223,12 +218,23 @@ "Blog", 1 ] - ], - "id" : "Stephen G Lynn" + ] + }, + { + "name" : "Ulrich Rieke", + "id" : "Ulrich Rieke", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ] }, { - "name" : "W. Luis Mochan", - "id" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -238,57 +244,45 @@ "Blog", 1 ] - ] + ], + "id" : "W. Luis Mochan", + "name" : "W. Luis Mochan" } ] }, - "xAxis" : { - "type" : "category" - }, - "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 - }, - "legend" : { - "enabled" : 0 - }, - "subtitle" : { - "text" : "[Champions: 19] Last updated at 2022-06-29 19:23:05 GMT" - }, "series" : [ { - "name" : "The Weekly Challenge - 171", + "colorByPoint" : 1, "data" : [ { - "drilldown" : "Ali Moradi", "y" : 2, - "name" : "Ali Moradi" + "name" : "Ali Moradi", + "drilldown" : "Ali Moradi" }, { - "name" : "Bartosz Jarzyna", "y" : 3, + "name" : "Bartosz Jarzyna", "drilldown" : "Bartosz Jarzyna" }, { "name" : "Dario Mazzeo", - "drilldown" : "Dario Mazzeo", - "y" : 1 + "y" : 1, + "drilldown" : "Dario Mazzeo" }, { "y" : 2, - "drilldown" : "Dave Jacoby", - "name" : "Dave Jacoby" + "name" : "Dave Jacoby", + "drilldown" : "Dave Jacoby" }, { - "drilldown" : "E. Choroba", + "name" : "E. Choroba", "y" : 2, - "name" : "E. Choroba" + "drilldown" : "E. Choroba" }, { "name" : "Humberto Massa", - "drilldown" : "Humberto Massa", - "y" : 2 + "y" : 2, + "drilldown" : "Humberto Massa" }, { "name" : "James Smith", @@ -296,29 +290,29 @@ "drilldown" : "James Smith" }, { - "y" : 2, "drilldown" : "Kjetil Skotheim", - "name" : "Kjetil Skotheim" + "name" : "Kjetil Skotheim", + "y" : 2 }, { - "name" : "Laurent Rosenfeld", + "drilldown" : "Laurent Rosenfeld", "y" : 5, - "drilldown" : "Laurent Rosenfeld" + "name" : "Laurent Rosenfeld" }, { "y" : 8, - "drilldown" : "Luca Ferrari", - "name" : "Luca Ferrari" + "name" : "Luca Ferrari", + "drilldown" : "Luca Ferrari" }, { "name" : "Marton Polgar", - "drilldown" : "Marton Polgar", - "y" : 2 + "y" : 2, + "drilldown" : "Marton Polgar" }, { - "y" : 2, "drilldown" : "Matthew Neleigh", - "name" : "Matthew Neleigh" + "name" : "Matthew Neleigh", + "y" : 2 }, { "drilldown" : "Mohammad S Anwar", @@ -326,29 +320,34 @@ "name" : "Mohammad S Anwar" }, { - "name" : "Philippe Bricout", "drilldown" : "Philippe Bricout", + "name" : "Philippe Bricout", "y" : 1 }, { - "name" : "Robert DiCicco", "drilldown" : "Robert DiCicco", - "y" : 2 + "y" : 2, + "name" : "Robert DiCicco" }, { - "drilldown" : "Robert Ransbottom", + "name" : "Robert Ransbottom", "y" : 2, - "name" : "Robert Ransbottom" + "drilldown" : "Robert Ransbottom" }, { - "y" : 4, "drilldown" : "Roger Bell_West", + "y" : 4, "name" : "Roger Bell_West" }, { + "y" : 5, "name" : "Stephen G Lynn", - "drilldown" : "Stephen G Lynn", - "y" : 5 + "drilldown" : "Stephen G Lynn" + }, + { + "name" : "Ulrich Rieke", + "y" : 4, + "drilldown" : "Ulrich Rieke" }, { "drilldown" : "W. Luis Mochan", @@ -356,18 +355,38 @@ "name" : "W. Luis Mochan" } ], - "colorByPoint" : 1 + "name" : "The Weekly Challenge - 171" } ], - "chart" : { - "type" : "column" - }, "yAxis" : { "title" : { "text" : "Total Solutions" } }, + "xAxis" : { + "type" : "category" + }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, + "subtitle" : { + "text" : "[Champions: 20] Last updated at 2022-06-29 22:29:29 GMT" + }, + "tooltip" : { + "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", + "followPointer" : 1, + "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>" + }, "title" : { "text" : "The Weekly Challenge - 171" + }, + "legend" : { + "enabled" : 0 } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 8cb248dad2..ed0feb209e 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,36 +1,10 @@ { - "xAxis" : { - "type" : "category", - "labels" : { - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - } - } - }, - "legend" : { - "enabled" : "false" - }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - }, "chart" : { "type" : "column" }, "series" : [ { - "dataLabels" : { - "rotation" : -90, - "enabled" : "true", - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - }, - "y" : 10, - "align" : "right", - "color" : "#FFFFFF", - "format" : "{point.y:.0f}" - }, + "name" : "Contributions", "data" : [ [ "Blog", @@ -38,26 +12,52 @@ ], [ "Perl", - 8322 + 8324 ], [ "Raku", - 4944 + 4946 ] ], - "name" : "Contributions" + "dataLabels" : { + "rotation" : -90, + "y" : 10, + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + }, + "color" : "#FFFFFF", + "format" : "{point.y:.0f}", + "enabled" : "true", + "align" : "right" + } } ], + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, "subtitle" : { - "text" : "Last updated at 2022-06-29 19:23:05 GMT" + "text" : "Last updated at 2022-06-29 22:29:29 GMT" + }, + "legend" : { + "enabled" : "false" + }, + "title" : { + "text" : "The Weekly Challenge Contributions [2019 - 2022]" }, "yAxis" : { - "min" : 0, "title" : { "text" : null - } + }, + "min" : 0 }, - "title" : { - "text" : "The Weekly Challenge Contributions [2019 - 2022]" + "xAxis" : { + "labels" : { + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + } + }, + "type" : "category" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 58244ebdbe..b321e77ef2 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,24 +1,12 @@ { - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "title" : { - "text" : "The Weekly Challenge Language" - }, - "legend" : { - "enabled" : "false" - }, - "tooltip" : { - "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>", - "followPointer" : "true", - "headerFormat" : "<span style=\"font-size:11px\"></span>" + "chart" : { + "type" : "column" }, "drilldown" : { "series" : [ { "id" : "001", + "name" : "001", "data" : [ [ "Perl", @@ -32,12 +20,9 @@ "Blog", 11 ] - ], - "name" : "001" + ] }, { - "name" : "002", - "id" : "002", "data" : [ [ "Perl", @@ -51,10 +36,11 @@ "Blog", 10 ] - ] + ], + "id" : "002", + "name" : "002" }, { - "name" : "003", "data" : [ [ "Perl", @@ -69,10 +55,12 @@ 9 ] ], - "id" : "003" + "id" : "003", + "name" : "003" }, { "id" : "004", + "name" : "004", "data" : [ [ "Perl", @@ -86,12 +74,9 @@ "Blog", 10 ] - ], - "name" : "004" + ] }, { - "name" : "005", - "id" : "005", "data" : [ [ "Perl", @@ -105,9 +90,13 @@ "Blog", 12 ] - ] + ], + "id" : "005", + "name" : "005" }, { + "id" : "006", + "name" : "006", "data" : [ [ "Perl", @@ -121,11 +110,10 @@ "Blog", 7 ] - ], - "id" : "006", - "name" : "006" + ] }, { + "id" : "007", "name" : "007", "data" : [ [ @@ -140,11 +128,11 @@ "Blog", 10 ] - ], - "id" : "007" + ] }, { "id" : "008", + "name" : "008", "data" : [ [ "Perl", @@ -158,8 +146,7 @@ "Blog", 12 ] - ], - "name" : "008" + ] }, { "name" : "009", @@ -180,6 +167,8 @@ ] }, { + "id" : "010", + "name" : "010", "data" : [ [ "Perl", @@ -193,11 +182,10 @@ "Blog", 11 ] - ], - "id" : "010", - "name" : "010" + ] }, { + "name" : "011", "id" : "011", "data" : [ [ @@ -212,11 +200,9 @@ "Blog", 10 ] - ], - "name" : "011" + ] }, { - "id" : "012", "data" : [ [ "Perl", @@ -231,7 +217,8 @@ 11 ] ], - "name" : "012" + "name" : "012", + "id" : "012" }, { "name" : "013", @@ -270,7 +257,6 @@ "name" : "014" }, { - "name" : "015", "data" : [ [ "Perl", @@ -285,11 +271,10 @@ 15 ] ], - "id" : "015" + "id" : "015", + "name" : "015" }, { - "name" : "016", - "id" : "016", "data" : [ [ "Perl", @@ -303,11 +288,11 @@ "Blog", 12 ] - ] + ], + "name" : "016", + "id" : "016" }, { - "name" : "017", - "id" : "017", "data" : [ [ "Perl", @@ -321,7 +306,9 @@ "Blog", 12 ] - ] + ], + "name" : "017", + "id" : "017" }, { "data" : [ @@ -342,7 +329,6 @@ "name" : "018" }, { - "name" : "019", "data" : [ [ "Perl", @@ -357,11 +343,10 @@ 13 ] ], + "name" : "019", "id" : "019" }, { - "name" : "020", - "id" : "020", "data" : [ [ "Perl", @@ -375,9 +360,13 @@ "Blog", 13 ] - ] + ], + "id" : "020", + "name" : "020" }, { + "id" : "021", + "name" : "021", "data" : [ [ "Perl", @@ -391,13 +380,9 @@ "Blog", 10 ] - ], - "id" : "021", - "name" : "021" + ] }, { - "name" : "022", - "id" : "022", "data" : [ [ "Perl", @@ -411,11 +396,11 @@ "Blog", 10 ] - ] + ], + "id" : "022", + "name" : "022" }, { - "name" : "023", - "id" : "023", "data" : [ [ "Perl", @@ -429,10 +414,13 @@ "Blog", 12 ] - ] + ], + "name" : "023", + "id" : "023" }, |
