diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-07-20 18:08:51 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-07-20 18:08:51 +0100 |
| commit | 78d8b4e0dd0b06529d9305d7bbfeadb1920006f7 (patch) | |
| tree | 2a9c64c6de1873826eeed2207c20315ec33f3083 | |
| parent | 5c9688d664111e3a22d5c20cf8929d979042028a (diff) | |
| download | perlweeklychallenge-club-78d8b4e0dd0b06529d9305d7bbfeadb1920006f7.tar.gz perlweeklychallenge-club-78d8b4e0dd0b06529d9305d7bbfeadb1920006f7.tar.bz2 perlweeklychallenge-club-78d8b4e0dd0b06529d9305d7bbfeadb1920006f7.zip | |
- Added solutions by Ulrich Rieke.
| -rw-r--r-- | challenge-122/ulrich-rieke/cpp/ch-1.cpp | 35 | ||||
| -rw-r--r-- | challenge-122/ulrich-rieke/haskell/ch-1.hs | 6 | ||||
| -rw-r--r-- | challenge-122/ulrich-rieke/haskell/ch-2.hs | 29 | ||||
| -rw-r--r-- | challenge-122/ulrich-rieke/perl/ch-1.pl | 23 | ||||
| -rw-r--r-- | challenge-122/ulrich-rieke/perl/ch-2.pl | 32 | ||||
| -rw-r--r-- | challenge-122/ulrich-rieke/raku/ch-1.raku | 19 | ||||
| -rw-r--r-- | stats/pwc-current.json | 259 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 62 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 892 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 764 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 100 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 46 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 102 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 94 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 80 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 100 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 94 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 38 |
19 files changed, 1489 insertions, 1326 deletions
diff --git a/challenge-122/ulrich-rieke/cpp/ch-1.cpp b/challenge-122/ulrich-rieke/cpp/ch-1.cpp new file mode 100644 index 0000000000..1b9568d367 --- /dev/null +++ b/challenge-122/ulrich-rieke/cpp/ch-1.cpp @@ -0,0 +1,35 @@ +#include <iostream> +#include <vector> +#include <algorithm> +#include <numeric> + +std::vector<int> enterArray( ) { + std::cout << "Enter different integers ( -1 to end ) !\n" ; + int i ; + std::vector<int> myIntegers ; + std::cin >> i ; + while ( i != -1 ) { + myIntegers.push_back( i ) ; + std::cin >> i ; + } + return myIntegers ; +} + +int main( ) { + std::vector<int> numbers = enterArray( ) ; + int len = static_cast<int>( numbers.size( ) ) ; + std::vector<double> averages ; + double av = 0.0 ; + int counted = 0 ; + int sum = 0 ; + for ( int num : numbers ) { + sum += num ; + counted++ ; + av = static_cast<double>( sum ) / static_cast<double>( counted ) ; + averages.push_back( av ) ; + } + for ( double n : averages ) + std::cout << n << " " ; + std::cout << std::endl ; + return 0 ; +} diff --git a/challenge-122/ulrich-rieke/haskell/ch-1.hs b/challenge-122/ulrich-rieke/haskell/ch-1.hs new file mode 100644 index 0000000000..de309bc706 --- /dev/null +++ b/challenge-122/ulrich-rieke/haskell/ch-1.hs @@ -0,0 +1,6 @@ +module Challenge122 + where + +solution :: [Int] -> [Double] +solution list = map(\p -> (fromIntegral $ sum $ take ( snd p ) list ) / +( fromIntegral $ snd p ) ) $ zip list [1 .. length list] diff --git a/challenge-122/ulrich-rieke/haskell/ch-2.hs b/challenge-122/ulrich-rieke/haskell/ch-2.hs new file mode 100644 index 0000000000..e342243142 --- /dev/null +++ b/challenge-122/ulrich-rieke/haskell/ch-2.hs @@ -0,0 +1,29 @@ +module Challenge122_2 + where +import Data.List ( permutations ) +import qualified Data.Set as S + +findRepetitions :: Int -> Int -> Int +findRepetitions num total = div total num + +findSomeLists :: [Int] -> Int -> [[Int]] +findSomeLists points total = concat $ map createList points +where + createList :: Int -> [[Int]] + createList i = [take howoften $ repeat i | howoften <- + [1 .. findRepetitions i total]] + +makeAllLists :: Int -> [[Int]] -> [[Int]] +makeAllLists total possibleLists = [ lista ++ listb | +lista <- possibleLists , listb <- possibleLists , sum ( lista ++ listb ) + == total ] + +solution :: Int -> [[Int]] +solution n = S.toList $ S.fromList $ concat $ map permutations totalList +where + basketball :: [Int] + basketball = [1 , 2 , 3] + someLists :: [[Int]] + someLists = findSomeLists basketball n + totalList :: [[Int]] + totalList = makeAllLists n someLists diff --git a/challenge-122/ulrich-rieke/perl/ch-1.pl b/challenge-122/ulrich-rieke/perl/ch-1.pl new file mode 100644 index 0000000000..e1a8822c05 --- /dev/null +++ b/challenge-122/ulrich-rieke/perl/ch-1.pl @@ -0,0 +1,23 @@ +#!/usr/bin/perl ; +use strict ; +use warnings ; +use feature 'say' ; + +sub enterArray { + say "Enter numbers, separated by blanks" ; + my $line = <STDIN> ; + chomp $line ; + my @array = split( /\s+/ , $line ) ; + return @array ; +} + +my @array = enterArray( ) ; +my @averages ; +my $len = scalar @array ; +my $sum = 0 ; +for my $i (0 .. $len - 1 ) { + $sum += $array[ $i ] ; + my $av = $sum / ( $i + 1 ) ; + push @averages , $av ; +} +say join( ", " , @averages ) ; diff --git a/challenge-122/ulrich-rieke/perl/ch-2.pl b/challenge-122/ulrich-rieke/perl/ch-2.pl new file mode 100644 index 0000000000..30ab2dd244 --- /dev/null +++ b/challenge-122/ulrich-rieke/perl/ch-2.pl @@ -0,0 +1,32 @@ +#!/usr/bin/perl ; +use strict ; +use warnings ; +use feature 'say' ; +use Algorithm::Combinatorics qw ( variations_with_repetition ) ; +use List::Util qw ( sum ) ; +use POSIX qw ( floor ) ; + +my $S = $ARGV[ 0 ] ; +my @basketballPoints = ( 1 , 2 , 3 ) ; +my @allCombis ; +my $maxtimes = $S ; #we can gather that many 1's from @basketballPoints +my $mintimes ; #the minimum number of 3 to arrive at $S points +if ( $S % 3 == 0 ) { + $mintimes = $S / 3 ; +} +else { + $mintimes = floor( $S / 3 ) + 1 ; +} +my $i = $maxtimes ; +while ( $i > $mintimes - 1 ) { + my $iter = variations_with_repetition(\@basketballPoints , $i ) ; + while ( my $c = $iter->next ) { + if ( sum( @$c ) == $S ) { + push @allCombis , $c ; + } + } + $i-- ; +} +for my $sequence( @allCombis ) { + say join( ' ' , @$sequence ) ; +} diff --git a/challenge-122/ulrich-rieke/raku/ch-1.raku b/challenge-122/ulrich-rieke/raku/ch-1.raku new file mode 100644 index 0000000000..4e00acaa0a --- /dev/null +++ b/challenge-122/ulrich-rieke/raku/ch-1.raku @@ -0,0 +1,19 @@ +use v6 ; + +sub enterArray( ) { + say "Enter an array, items separated by blanks!" ; + my $line = $*IN.get ; + my @array = $line.split( /\s+/ ) ; + return @array ; +} + +my @array = enterArray( ) ; +my @averages ; +my $len = @array.elems ; +my $sum = 0 ; +for (0 .. $len - 1 ) -> $i { + $sum += @array[ $i ] ; + my $av = $sum / ( $i + 1 ) ; + @averages.push( $av ) ; +} +say @averages.join( ", " ) ; diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 376bec2858..10f3cf59aa 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,17 +1,121 @@ { + "subtitle" : { + "text" : "[Champions: 12] Last updated at 2021-07-20 17:05:39 GMT" + }, + "chart" : { + "type" : "column" + }, + "title" : { + "text" : "The Weekly Challenge - 122" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "legend" : { + "enabled" : 0 + }, + "series" : [ + { + "data" : [ + { + "y" : 2, + "drilldown" : "Cheok-Yin Fung", + "name" : "Cheok-Yin Fung" + }, + { + "name" : "Dave Jacoby", + "drilldown" : "Dave Jacoby", + "y" : 3 + }, + { + "y" : 3, + "name" : "James Smith", + "drilldown" : "James Smith" + }, + { + "y" : 4, + "drilldown" : "Luca Ferrari", + "name" : "Luca Ferrari" + }, + { + "drilldown" : "Lucas Ransan", + "name" : "Lucas Ransan", + "y" : 2 + }, + { + "y" : 2, + "name" : "Mark Anderson", + "drilldown" : "Mark Anderson" + }, + { + "drilldown" : "Niels van Dijke", + "name" : "Niels van Dijke", + "y" : 2 + }, + { + "name" : "Peter Scott", + "drilldown" : "Peter Scott", + "y" : 1 + }, + { + "y" : 3, + "drilldown" : "Roger Bell_West", + "name" : "Roger Bell_West" + }, + { + "y" : 4, + "drilldown" : "Stuart Little", + "name" : "Stuart Little" + }, + { + "drilldown" : "Ulrich Rieke", + "name" : "Ulrich Rieke", + "y" : 3 + }, + { + "y" : 3, + "name" : "W. Luis Mochan", + "drilldown" : "W. Luis Mochan" + } + ], + "name" : "The Weekly Challenge - 122", + "colorByPoint" : 1 + } + ], + "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/>" + }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, + "xAxis" : { + "type" : "category" + }, "drilldown" : { "series" : [ { "name" : "Cheok-Yin Fung", - "id" : "Cheok-Yin Fung", "data" : [ [ "Perl", 2 ] - ] + ], + "id" : "Cheok-Yin Fung" }, { + "name" : "Dave Jacoby", + "id" : "Dave Jacoby", "data" : [ [ "Perl", @@ -21,13 +125,9 @@ "Blog", 1 ] - ], - "name" : "Dave Jacoby", - "id" : "Dave Jacoby" + ] }, { - "name" : "James Smith", - "id" : "James Smith", "data" : [ [ "Perl", @@ -37,11 +137,12 @@ "Blog", 1 ] - ] + ], + "id" : "James Smith", + "name" : "James Smith" }, { "id" : "Luca Ferrari", - "name" : "Luca Ferrari", "data" : [ [ "Raku", @@ -51,31 +152,32 @@ "Blog", 2 ] - ] + ], + "name" : "Luca Ferrari" }, { "name" : "Lucas Ransan", - "id" : "Lucas Ransan", "data" : [ [ "Raku", 2 ] - ] + ], + "id" : "Lucas Ransan" }, { + "id" : "Mark Anderson", "data" : [ [ "Raku", 2 ] ], - "name" : "Mark Anderson", - "id" : "Mark Anderson" + "name" : "Mark Anderson" }, { - "id" : "Niels van Dijke", "name" : "Niels van Dijke", + "id" : "Niels van Dijke", "data" : [ [ "Perl", @@ -84,17 +186,16 @@ ] }, { + "name" : "Peter Scott", + "id" : "Peter Scott", "data" : [ [ "Perl", 1 ] - ], - "name" : "Peter Scott", - "id" : "Peter Scott" + ] }, { - "id" : "Roger Bell_West", "name" : "Roger Bell_West", "data" : [ [ @@ -105,11 +206,10 @@ "Raku", 1 ] - ] + ], + "id" : "Roger Bell_West" }, { - "name" : "Stuart Little", - "id" : "Stuart Little", "data" : [ [ "Perl", @@ -119,11 +219,27 @@ "Raku", 2 ] + ], + "id" : "Stuart Little", + "name" : "Stuart Little" + }, + { + "name" : "Ulrich Rieke", + "id" : "Ulrich Rieke", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 1 + ] ] }, { - "id" : "W. Luis Mochan", "name" : "W. Luis Mochan", + "id" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -136,102 +252,5 @@ ] } ] - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "series" : [ - { - "name" : "The Weekly Challenge - 122", - "data" : [ - { - "name" : "Cheok-Yin Fung", - "drilldown" : "Cheok-Yin Fung", - "y" : 2 - }, - { - "y" : 3, - "drilldown" : "Dave Jacoby", - "name" : "Dave Jacoby" - }, - { - "y" : 3, - "drilldown" : "James Smith", - "name" : "James Smith" - }, - { - "drilldown" : "Luca Ferrari", - "y" : 4, - "name" : "Luca Ferrari" - }, - { - "name" : "Lucas Ransan", - "y" : 2, - "drilldown" : "Lucas Ransan" - }, - { - "name" : "Mark Anderson", - "drilldown" : "Mark Anderson", - "y" : 2 - }, - { - "name" : "Niels van Dijke", - "y" : 2, - "drilldown" : "Niels van Dijke" - }, - { - "drilldown" : "Peter Scott", - "y" : 1, - "name" : "Peter Scott" - }, - { - "name" : "Roger Bell_West", - "y" : 3, - "drilldown" : "Roger Bell_West" - }, - { - "name" : "Stuart Little", - "y" : 4, - "drilldown" : "Stuart Little" - }, - { - "y" : 3, - "drilldown" : "W. Luis Mochan", - "name" : "W. Luis Mochan" - } - ], - "colorByPoint" : 1 - } - ], - "plotOptions" : { - "series" : { - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 - } - }, - "chart" : { - "type" : "column" - }, - "legend" : { - "enabled" : 0 - }, - "xAxis" : { - "type" : "category" - }, - "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/>" - }, - "title" : { - "text" : "The Weekly Challenge - 122" - }, - "subtitle" : { - "text" : "[Champions: 11] Last updated at 2021-07-20 16:21:42 GMT" } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 98074f16db..30110526bc 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -2,30 +2,6 @@ "legend" : { "enabled" : "false" }, - "xAxis" : { - "labels" : { - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - } - }, - "type" : "category" - }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - }, - "title" : { - "text" : "The Weekly Challenge Contributions [2019 - 2021]" - }, - "subtitle" : { - "text" : "Last updated at 2021-07-20 16:21:42 GMT" - }, - "yAxis" : { - "title" : { - "text" : null - }, - "min" : 0 - }, "series" : [ { "name" : "Contributions", @@ -36,28 +12,52 @@ ], [ "Perl", - 5817 + 5819 ], [ "Raku", - 3634 + 3635 ] ], "dataLabels" : { + "enabled" : "true", + "format" : "{point.y:.0f}", "y" : 10, - "align" : "right", "color" : "#FFFFFF", - "format" : "{point.y:.0f}", - "enabled" : "true", + "align" : "right", "rotation" : -90, "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" } } } ], + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "xAxis" : { + "labels" : { + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + } + }, + "type" : "category" + }, + "title" : { + "text" : "The Weekly Challenge Contributions [2019 - 2021]" + }, + "yAxis" : { + "title" : { + "text" : null + }, + "min" : 0 + }, "chart" : { "type" : "column" + }, + "subtitle" : { + "text" : "Last updated at 2021-07-20 17:05:39 GMT" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index b0da5686c4..6507147965 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,9 +1,23 @@ { + "title" : { + "text" : "The Weekly Challenge Language" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "subtitle" : { + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2021-07-20 17:05:39 GMT" + }, + "chart" : { + "type" : "column" + }, "drilldown" : { "series" : [ { - "id" : "001", "name" : "001", + "id" : "001", "data" : [ [ "Perl", @@ -20,6 +34,8 @@ ] }, { + "name" : "002", + "id" : "002", "data" : [ [ "Perl", @@ -33,13 +49,10 @@ "Blog", 10 ] - ], - "name" : "002", - "id" : "002" + ] }, { "id" : "003", - "name" : "003", "data" : [ [ "Perl", @@ -53,11 +66,12 @@ "Blog", 9 ] - ] + ], + "name" : "003" }, { - "id" : "004", "name" : "004", + "id" : "004", "data" : [ [ "Perl", @@ -74,6 +88,7 @@ ] }, { + "name" : "005", "data" : [ [ "Perl", @@ -88,8 +103,7 @@ 12 ] ], - "id" : "005", - "name" : "005" + "id" : "005" }, { "data" : [ @@ -110,8 +124,6 @@ "name" : "006" }, { - "name" : "007", - "id" : "007", "data" : [ [ "Perl", @@ -125,10 +137,11 @@ "Blog", 10 ] - ] + ], + "id" : "007", + "name" : "007" }, { - "id" : "008", "name" : "008", "data" : [ [ @@ -143,9 +156,11 @@ "Blog", 12 ] - ] + ], + "id" : "008" }, { + "name" : "009", "data" : [ [ "Perl", @@ -160,12 +175,11 @@ 13 ] ], - "name" : "009", "id" : "009" }, { - "id" : "010", "name" : "010", + "id" : "010", "data" : [ [ "Perl", @@ -182,6 +196,8 @@ ] }, { + "name" : "011", + "id" : "011", "data" : [ [ "Perl", @@ -195,11 +211,10 @@ "Blog", 10 ] - ], - "id" : "011", - "name" : "011" + ] }, { + "name" : "012", "data" : [ [ "Perl", @@ -214,10 +229,10 @@ 11 ] ], - "id" : "012", - "name" : "012" + "id" : "012" }, { + "id" : "013", "data" : [ [ "Perl", @@ -232,10 +247,10 @@ 13 ] ], - "id" : "013", "name" : "013" }, { + "id" : "014", "data" : [ [ "Perl", @@ -250,12 +265,9 @@ 15 ] ], - "name" : "014", - "id" : "014" + "name" : "014" }, { - "id" : "015", - "name" : "015", "data" : [ [ "Perl", @@ -269,11 +281,11 @@ "Blog", 15 ] - ] + ], + "id" : "015", + "name" : "015" }, { - "name" : "016", - "id" : "016", "data" : [ [ "Perl", @@ -287,10 +299,11 @@ "Blog", 12 ] - ] + ], + "id" : "016", + "name" : "016" }, { - "name" : "017", "id" : "017", "data" : [ [ @@ -305,7 +318,8 @@ "Blog", 12 ] - ] + ], + "name" : "017" }, { "data" : [ @@ -326,6 +340,7 @@ "name" : "018" }, { + "name" : "019", "data" : [ [ "Perl", @@ -340,10 +355,10 @@ 13 ] ], - "name" : "019", "id" : "019" }, { + "id" : "020", "data" : [ [ "Perl", @@ -358,12 +373,10 @@ 13 ] ], - "name" : "020", - "id" : "020" + "name" : "020" }, { "id" : "021", - "name" : "021", "data" : [ [ "Perl", @@ -377,9 +390,11 @@ "Blog", 10 ] - ] + ], + "name" : "021" }, { + "id" : "022", "data" : [ [ "Perl", @@ -394,12 +409,9 @@ 10 ] ], - "id" : "022", "name" : "022" }, { - "name" : "023", - "id" : "023", "data" : [ [ "Perl", @@ -413,7 +425,9 @@ "Blog", 12 ] - ] + ], + "id" : "023", + "name" : "023" }, { "data" : [ @@ -430,12 +444,10 @@ 11 ] ], - "name" : "024", - "id" : "024" + "id" : "024", + "name" : "024" }, { - "id" : "025", - "name" : "025", "data" : [ [ "Perl", @@ -449,7 +461,9 @@ "Blog", 12 ] - ] + ], + "id" : "025", + "name" : "025" }, { "data" : [ @@ -471,7 +485,6 @@ }, { "name" : "027", - "id" : "027", "data" : [ [ "Perl", @@ -485,9 +498,11 @@ "Blog", 9 ] - ] + ], + "id" : "027" }, { + "name" : "028", "data" : [ [ "Perl", @@ -502,11 +517,9 @@ 9 ] ], - "id" : "028", - "name" : "028" + "id" : "028" }, { - "name" : "029", "id" : "029", "data" : [ [ @@ -521,9 +534,12 @@ "Blog", 12 ] - ] + ], + "name" : "029" }, { + "name" : "030", + "id" : "030", "data" : [ [ "Perl", @@ -537,13 +553,9 @@ "Blog", 10 ] - ], - "id" : "030", - "name" : "030" + ] }, { - "name" : "031", - "id" : "031", "data" : [ [ "Perl", @@ -557,7 +569,9 @@ "Blog", 9 ] - ] + ], + "id" : "031", + "name" : "031" }, { "data" : [ @@ -574,8 +588,8 @@ 10 ] ], - "name" : "032", - "id" : "032" + "id" : "032", + "name" : "032" }, { "data" : [ @@ -592,8 +606,8 @@ 10 ] ], - "name" : "033", - "id" : "033" + "id" : "033", + "name" : "033" }, { |
