aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2023-10-08 19:51:46 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2023-10-08 19:51:46 +0100
commit07e42d14bd2245214cbfde133ce9ffbc0d7fd227 (patch)
treef7221c561a7311a68ebcdbf14b6c41679e9c61b0
parent5539cbce1f10da0f59ef4623f45d6d13b65bd796 (diff)
downloadperlweeklychallenge-club-07e42d14bd2245214cbfde133ce9ffbc0d7fd227.tar.gz
perlweeklychallenge-club-07e42d14bd2245214cbfde133ce9ffbc0d7fd227.tar.bz2
perlweeklychallenge-club-07e42d14bd2245214cbfde133ce9ffbc0d7fd227.zip
- Added solutions by Robert DiCicco.
- Added solutions by Packy Anderson. - Added solutions by Lubos Kolouch. - Added solutions by Dave Jacoby. - Added solutions by Jorg Sommrey. - Added solutions by Ali Moradi. - Added solutions by Avery Adams. - Added solutions by Bob Lied. - Added solutions by Steven Wilson. - Added solutions by Athanasius. - Added solutions by Flavio Poletti. - Added solutions by Matthias Muth. - Added solutions by Robert Ransbottom. - Added solutions by Simon Green. - Added solutions by Yves Orton. - Added solutions by Mark Anderson. - Added solutions by Ulrich Rieke. - Added solutions by Robbie Hatley.
-rw-r--r--challenge-237/avery-adams/blog.txt1
-rw-r--r--challenge-237/avery-adams/blog1.txt (renamed from challenge-237/avery-adams/blogs.txt)1
-rw-r--r--challenge-237/robert-dicicco/julia/ch-2.jl60
-rw-r--r--challenge-237/robert-dicicco/perl/ch-2.pl60
-rw-r--r--challenge-237/robert-dicicco/powershell/ch-2.psl55
-rw-r--r--challenge-237/robert-dicicco/python/ch-2.py51
-rw-r--r--challenge-237/robert-dicicco/raku/ch-2.raku56
-rw-r--r--challenge-237/robert-dicicco/ruby/ch-2.rb55
-rw-r--r--challenge-237/steven-wilson/python/ch-1.py (renamed from challenge-237/steven-wilson/python/ch-01.py)0
-rw-r--r--challenge-237/steven-wilson/python/ch-2.py (renamed from challenge-237/steven-wilson/python/ch-02.py)0
-rwxr-xr-xchallenge-237/ulrich-rieke/cpp/ch-2.cpp47
-rwxr-xr-xchallenge-237/ulrich-rieke/haskell/ch-1.hs41
-rwxr-xr-xchallenge-237/ulrich-rieke/haskell/ch-2.hs21
-rwxr-xr-xchallenge-237/ulrich-rieke/perl/ch-1.pl40
-rwxr-xr-xchallenge-237/ulrich-rieke/perl/ch-2.pl25
-rwxr-xr-xchallenge-237/ulrich-rieke/raku/ch-1.raku26
-rwxr-xr-xchallenge-237/ulrich-rieke/raku/ch-2.raku20
-rwxr-xr-xchallenge-237/ulrich-rieke/rust/ch-1.rs33
-rwxr-xr-xchallenge-237/ulrich-rieke/rust/ch-2.rs27
-rw-r--r--stats/pwc-challenge-229.json563
-rw-r--r--stats/pwc-challenge-236.json528
-rw-r--r--stats/pwc-current.json445
-rw-r--r--stats/pwc-language-breakdown-summary.json96
-rw-r--r--stats/pwc-language-breakdown.json3318
-rw-r--r--stats/pwc-leaders.json812
-rw-r--r--stats/pwc-summary-1-30.json106
-rw-r--r--stats/pwc-summary-121-150.json42
-rw-r--r--stats/pwc-summary-151-180.json42
-rw-r--r--stats/pwc-summary-181-210.json100
-rw-r--r--stats/pwc-summary-211-240.json110
-rw-r--r--stats/pwc-summary-241-270.json102
-rw-r--r--stats/pwc-summary-271-300.json44
-rw-r--r--stats/pwc-summary-31-60.json112
-rw-r--r--stats/pwc-summary-61-90.json60
-rw-r--r--stats/pwc-summary-91-120.json46
-rw-r--r--stats/pwc-summary.json106
36 files changed, 4088 insertions, 3163 deletions
diff --git a/challenge-237/avery-adams/blog.txt b/challenge-237/avery-adams/blog.txt
new file mode 100644
index 0000000000..7bf8ae3516
--- /dev/null
+++ b/challenge-237/avery-adams/blog.txt
@@ -0,0 +1 @@
+https://dev.to/oldtechaa/perl-weekly-challenge-237-carpe-diem-1i09
diff --git a/challenge-237/avery-adams/blogs.txt b/challenge-237/avery-adams/blog1.txt
index 1fed97a89c..ef268625bd 100644
--- a/challenge-237/avery-adams/blogs.txt
+++ b/challenge-237/avery-adams/blog1.txt
@@ -1,2 +1 @@
-https://dev.to/oldtechaa/perl-weekly-challenge-237-carpe-diem-1i09
https://blogs.perl.org/users/oldtechaa/2023/10/perl-weekly-challenge-237---carpe-diem.html
diff --git a/challenge-237/robert-dicicco/julia/ch-2.jl b/challenge-237/robert-dicicco/julia/ch-2.jl
new file mode 100644
index 0000000000..1859cb952e
--- /dev/null
+++ b/challenge-237/robert-dicicco/julia/ch-2.jl
@@ -0,0 +1,60 @@
+#!usr/bin/env julia
+#=
+-----------------------------------------
+AUTHOR: Robert DiCicco
+DATE : 2023-10-05
+Challenge 237 Task 02 Maximise Greatness ( Julia )
+-----------------------------------------
+=#
+using Printf
+using Combinatorics
+
+mynums = [[1, 3, 5, 2, 1, 3, 1], [1, 2, 3, 4]]
+
+maxscore = 0;
+score = 0;
+
+function CalcScore(a,b)
+ cnt = 1
+ score = 0
+ while cnt < length(a)
+ if a[cnt] < b[cnt]
+ score += 1
+ end
+ cnt += 1
+ end
+ return score
+end
+
+for nums in mynums
+ global maxscore,score
+ @printf("Input: @nums = %s\n",nums)
+ maxscore = 0
+ p = collect(permutations(nums,length(nums)))
+ for perm in p
+ score = 0
+ score = CalcScore(nums, perm)
+ ignore = floor(length(nums) / 2 + 1)
+ if score >= maxscore && score >= ignore
+ maxscore = score
+ end
+ end
+ @printf("Output: %s\n\n",maxscore)
+end
+
+#=
+-----------------------------------------
+SAMPLE OUTPUT
+julia .\MaximiseGreatness.jl
+
+Input: @nums = [1, 3, 5, 2, 1, 3, 1]
+Output: 4
+
+Input: @nums = [1, 2, 3, 4]
+Output: 3
+-----------------------------------------
+=#
+
+
+
+
diff --git a/challenge-237/robert-dicicco/perl/ch-2.pl b/challenge-237/robert-dicicco/perl/ch-2.pl
new file mode 100644
index 0000000000..51e5ba9cca
--- /dev/null
+++ b/challenge-237/robert-dicicco/perl/ch-2.pl
@@ -0,0 +1,60 @@
+#!/usr/bin/env perl
+=begin comment
+-----------------------------------------
+AUTHOR: Robert DiCicco
+DATE : 2023-10-05
+Challenge 237 Task 02 Maximise Greatness ( Perl )
+-----------------------------------------
+=cut
+use v5.38;
+use Algorithm::Permute;
+
+my @mynums = ([1, 3, 5, 2, 1, 3, 1], [1, 2, 3, 4]);
+
+my $maxscore = 0;
+my $score = 0;
+
+my @output = [];
+
+sub CalcScore ($a,$b) {
+ my $cnt = 0;
+ my $score = 0;
+ while($cnt < scalar @$a) {
+ if ($a->[$cnt] < $b->[$cnt]) {
+ $score++;
+ }
+ $cnt++;
+ }
+ return $score;
+}
+
+for my $nums ( @mynums) {
+ say "Input: \@nums = [@$nums]";
+ $maxscore = 0;
+ my @sec = @$nums;
+ my $p = Algorithm::Permute->new(\@sec);
+ while ( my @perm = $p->next) {
+ $score = 0;
+ $score = CalcScore($nums, \@perm);
+ my $ignore = int((scalar @$nums / 2) + 1);
+ if ($score >= $maxscore and $score >= $ignore) {
+ $maxscore = $score;
+ }
+ }
+ say "Output: $maxscore\n";
+}
+
+=begin comment
+-----------------------------------------
+SAMPLE OUTPUT
+perl .\MaximiseGreatness.pl
+
+Input: @nums = [1 3 5 2 1 3 1]
+Output: 4
+
+Input: @nums = [1 2 3 4]
+Output: 3
+-----------------------------------------
+=cut
+
+
diff --git a/challenge-237/robert-dicicco/powershell/ch-2.psl b/challenge-237/robert-dicicco/powershell/ch-2.psl
new file mode 100644
index 0000000000..068e457ee6
--- /dev/null
+++ b/challenge-237/robert-dicicco/powershell/ch-2.psl
@@ -0,0 +1,55 @@
+$mynums = @((1, 3, 5, 2, 1, 3, 1), (1, 2, 3, 4))
+<#
+-----------------------------------------
+AUTHOR: Robert DiCicco
+DATE : 2023-10-07
+Challenge 237 Task 02 Maximise Greatness ( Powershell )
+-----------------------------------------
+ #>
+
+$maxscore = 0
+$score = 0
+$output = @()
+
+function CalcScore($a, $b) {
+ $cnt = 0
+ $score = 0
+ while ($cnt -lt $a.length) {
+ if ($a[$cnt] -lt $b[$cnt]) {
+ $score += 1
+ }
+ $cnt += 1
+ }
+ return $score
+}
+
+
+foreach ($nums in $mynums ) {
+ write-host "Input: @nums = [$nums]"
+ $maxscore = 0
+ Get-Permutation $nums | ForEach-Object {
+ $perm = $_ -replace ' ',''
+ $num1 = $nums -replace ' ',''
+ $score = CalcScore $num1 $perm
+ $ignore = [math]::floor(($num1.length / 2 + 1))
+ if ($score -ge $maxscore -and $score -ge $ignore) {
+ $maxscore = $score
+ }
+ }
+ write-host "Output $maxscore`n"
+}
+
+<#
+-----------------------------------------
+SAMPLE OUTPUT
+.\MaximiseGreatness.ps1
+
+Input: @nums = [1 3 5 2 1 3 1]
+Output 4
+
+Input: @nums = [1 2 3 4]
+Output 3
+-----------------------------------------
+ #>
+
+
diff --git a/challenge-237/robert-dicicco/python/ch-2.py b/challenge-237/robert-dicicco/python/ch-2.py
new file mode 100644
index 0000000000..27120ea8f9
--- /dev/null
+++ b/challenge-237/robert-dicicco/python/ch-2.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+'''
+-----------------------------------------
+AUTHOR: Robert DiCicco
+DATE : 2023-10-06
+Challenge 237 Task 02 Maximise Greatness ( Python )
+-----------------------------------------
+'''
+
+from itertools import permutations
+import math
+
+mynums = [[1, 3, 5, 2, 1, 3, 1], [1, 2, 3, 4]]
+
+maxscore = 0;
+score = 0;
+
+def CalcScore(a,b):
+ cnt = 0
+ score = 0
+ while cnt < len(a):
+ if a[cnt] < b[cnt]:
+ score += 1
+ cnt += 1
+ return score
+
+for nums in mynums:
+ print(f"Input: @nums = {nums}")
+ maxscore = 0
+ p = permutations(nums)
+ for perm in list(p):
+ score = CalcScore(nums, perm)
+ ignore = math.floor(len(nums) / 2 + 1)
+ if score >= maxscore and score >= ignore:
+ maxscore = score
+ print(f"Output: {maxscore}\n")
+
+'''
+-----------------------------------------
+SAMPLE OUTPUT
+python .\MaximiseGreatness.py
+
+Input: @nums = [1, 3, 5, 2, 1, 3, 1]
+Output: 4
+
+Input: @nums = [1, 2, 3, 4]
+Output: 3
+-----------------------------------------
+'''
+
+
diff --git a/challenge-237/robert-dicicco/raku/ch-2.raku b/challenge-237/robert-dicicco/raku/ch-2.raku
new file mode 100644
index 0000000000..9c4efebed1
--- /dev/null
+++ b/challenge-237/robert-dicicco/raku/ch-2.raku
@@ -0,0 +1,56 @@
+#!/usr/bin/env raku
+=begin comment
+-----------------------------------------
+AUTHOR: Robert DiCicco
+DATE : 2023-10-05
+Challenge 237 Task 02 Maximise Greatness ( Raku )
+-----------------------------------------
+=end comment
+
+my @mynums = ([1, 3, 5, 2, 1, 3, 1], [1, 2, 3, 4]);
+
+my $maxscore = 0;
+my $score = 0;
+my @output = [];
+
+sub CalcScore (@a,@b) {
+ my $cnt = 0;
+ my $score = 0;
+ while ($cnt < @a.elems) {
+ if (@a[$cnt] < @b[$cnt]) {
+ $score++;
+ }
+ $cnt++;
+ }
+ return $score;
+}
+
+for @mynums -> @nums {
+ say "Input: \@nums = ",@nums;
+ $maxscore = 0;
+ my @sec = @nums;
+ for @sec.permutations -> @perm {
+ $score = 0;
+ $score = CalcScore(@nums, @perm);
+ my $ignore = floor(@nums.elems / 2 + 1);
+ if ($score >= $maxscore and $score >= $ignore) {
+ $maxscore = $score;
+ }
+ }
+ say "Output: $maxscore\n";
+}
+
+=begin comment
+-----------------------------------------
+SAMPLE OUTPUT
+ raku .\MaximiseGreatness.rk
+
+Input: @nums = [1 3 5 2 1 3 1]
+Output: 4
+
+Input: @nums = [1 2 3 4]
+Output: 3
+-----------------------------------------
+=end comment
+
+
diff --git a/challenge-237/robert-dicicco/ruby/ch-2.rb b/challenge-237/robert-dicicco/ruby/ch-2.rb
new file mode 100644
index 0000000000..a779fcb6b7
--- /dev/null
+++ b/challenge-237/robert-dicicco/ruby/ch-2.rb
@@ -0,0 +1,55 @@
+#!/usr/bin/env ruby
+=begin
+-----------------------------------------
+AUTHOR: Robert DiCicco
+DATE : 2023-10-05
+Challenge 237 Task 02 Maximise Greatness ( Ruby )
+-----------------------------------------
+=end
+
+mynums = [[1, 3, 5, 2, 1, 3, 1], [1, 2, 3, 4]]
+
+maxscore = 0;
+score = 0;
+output = [];
+
+def CalcScore (a,b)
+ cnt = 0;
+ score = 0;
+ while cnt < a.length()
+ if a[cnt] < b[cnt]
+ score += 1
+ end
+ cnt += 1
+ end
+ return score;
+end
+
+mynums.each do |nums|
+ puts("Input: @nums = #{nums}")
+ maxscore = 0;
+ nums.permutation.to_a.each do |perm|
+ score = 0
+ score = CalcScore(nums, perm)
+ ignore = (nums.length() / 2 + 1).floor()
+ if score >= maxscore && score >= ignore
+ maxscore = score
+ end
+ end
+ puts("Output: #{maxscore}\n\n")
+end
+
+=begin
+-----------------------------------------
+SAMPLE OUTPUT
+ruby .\MaximiseGreatness.rb
+
+Input: @nums = [1, 3, 5, 2, 1, 3, 1]
+Output: 4
+
+Input: @nums = [1, 2, 3, 4]
+Output: 3
+-----------------------------------------
+=end
+
+
diff --git a/challenge-237/steven-wilson/python/ch-01.py b/challenge-237/steven-wilson/python/ch-1.py
index 6da63f3aa6..6da63f3aa6 100644
--- a/challenge-237/steven-wilson/python/ch-01.py
+++ b/challenge-237/steven-wilson/python/ch-1.py
diff --git a/challenge-237/steven-wilson/python/ch-02.py b/challenge-237/steven-wilson/python/ch-2.py
index c7ff7edd00..c7ff7edd00 100644
--- a/challenge-237/steven-wilson/python/ch-02.py
+++ b/challenge-237/steven-wilson/python/ch-2.py
diff --git a/challenge-237/ulrich-rieke/cpp/ch-2.cpp b/challenge-237/ulrich-rieke/cpp/ch-2.cpp
new file mode 100755
index 0000000000..02fec12a09
--- /dev/null
+++ b/challenge-237/ulrich-rieke/cpp/ch-2.cpp
@@ -0,0 +1,47 @@
+#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 ) //convert to vector of ints
+ numbers.push_back( std::stoi( s ) ) ;
+ int len = numbers.size( ) ;
+ //if we want to create successive permutations, we have to sort
+ //the vector of numbers we entered. Subsequently, we create
+ //permutations on it. To have something to compare to we have to
+ //create a copy of the numbers
+ std::vector<int> original_numbers( numbers ) ;
+ int max_greatness = 0 ;
+ std::sort( numbers.begin( ) , numbers.end( ) ) ;
+ while ( std::next_permutation( numbers.begin( ) , numbers.end( ) ) ) {
+ int current_greatness = 0 ;
+ for ( int i = 0 ; i < len ; i++ ) {
+ if ( numbers[ i ] > original_numbers[ i ] ) {
+ current_greatness++ ;
+ }
+ }
+ if ( current_greatness > max_greatness )
+ max_greatness = current_greatness ;
+ }
+ std::cout << max_greatness << std::endl ;
+ return 0 ;
+}
diff --git a/challenge-237/ulrich-rieke/haskell/ch-1.hs b/challenge-237/ulrich-rieke/haskell/ch-1.hs
new file mode 100755
index 0000000000..c91c55dd4b
--- /dev/null
+++ b/challenge-237/ulrich-rieke/haskell/ch-1.hs
@@ -0,0 +1,41 @@
+module Challenge237
+ where
+import Data.Time.Calendar
+import Data.Maybe ( fromJust )
+import Data.List ( (!!) )
+
+numToDayOfWeek :: [(Int , DayOfWeek)]
+numToDayOfWeek = zip [1..7] [Monday, Tuesday , Wednesday, Thursday, Friday, Saturday ,
+ Sunday]
+
+findFirstSuitableWeekday :: Day -> DayOfWeek -> Day
+findFirstSuitableWeekday d wd
+ |dayOfWeek d == wd = d
+ |otherwise = until ( (== wd ) . dayOfWeek ) ( addDays 1 ) d
+
+findFinalDay :: Day -> Int -> Day
+findFinalDay d pos
+ |pos == 1 = d
+ |otherwise = addDays ( toInteger ((pos - 1) * 7 )) d
+
+getDay :: Day -> Int
+getDay day = d
+ where
+ (_ , _ , d ) = toGregorian day
+
+getMonth :: Day -> Int
+getMonth day = mo
+ where
+ (_ , mo , _) = toGregorian day
+
+main :: IO ( )
+main = do
+ putStrLn "Enter a year( positive integer ) , a month( integer from 1 to 12 ) ,"
+ putStrLn "a weekday position( integer from 1 to 5 ) and a weekday ( from 1 to 7 )!"
+ datepartsStr <- getLine
+ let dateParts = map read $ words datepartsStr
+ startDay = fromGregorian ( toInteger $ head dateParts ) (dateParts !! 1 ) 1
+ wantedWeekday = fromJust $ lookup ( dateParts !! 3 ) numToDayOfWeek
+ firstWeekday = findFirstSuitableWeekday startDay wantedWeekday
+ finalDay = findFinalDay firstWeekday ( dateParts !! 2 )
+ if (getMonth finalDay) /= dateParts !! 1 then print 0 else print ( getDay finalDay )
diff --git a/challenge-237/ulrich-rieke/haskell/ch-2.hs b/challenge-237/ulrich-rieke/haskell/ch-2.hs
new file mode 100755
index 0000000000..5692e05732
--- /dev/null
+++ b/challenge-237/ulrich-rieke/haskell/ch-2.hs
@@ -0,0 +1,21 @@
+module Challenge237_2
+ where
+import Data.List ( permutations )
+
+solution :: [Int] -> Int
+solution list = maximum greaterNums
+ where
+ permus :: [[Int]]
+ permus = permutations list
+ listPairs :: [[(Int , Int)]]
+ listPairs = map (\perm -> zip perm list) permus
+ greaterNums :: [Int]
+ greaterNums = map (\p -> length $ filter(\pa -> fst pa > snd pa ) p )
+ listPairs
+
+main :: IO ( )
+main = do
+ putStrLn "Please enter some integers, separated by blanks!"
+ numberstrings <- getLine
+ let numbers = map read $ words numberstrings
+ print $ solution numbers
diff --git a/challenge-237/ulrich-rieke/perl/ch-1.pl b/challenge-237/ulrich-rieke/perl/ch-1.pl
new file mode 100755
index 0000000000..ff8680aab0
--- /dev/null
+++ b/challenge-237/ulrich-rieke/perl/ch-1.pl
@@ -0,0 +1,40 @@
+#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+use DateTime ;
+
+say "Enter a year ( positive integer ) , a month ( integer from 1 to 12 ) ," ;
+say "a weekday index ( integer from 1 to 5 ) and a weekday( integer from 1 to 7 )!" ;
+my $line = <STDIN> ;
+chomp $line ;
+my @dateParts = split( /\s/ , $line ) ;
+my $d = DateTime->new(
+ year => $dateParts[ 0 ] ,
+ month => $dateParts[ 1 ] ,
+ day => 1 ,
+ hour => 0 ,
+ minute => 0 ,
+ second => 0 ,
+ nanosecond => 0 ,
+ time_zone => 'Europe/Berlin' ,
+) ;
+my $dt = $d->set_time_zone( 'floating' ) ; #for doing date math
+#add 1 day until we've reached the desired weekday
+while ( $dt->day_of_week != $dateParts[ 3 ] ) {
+ $dt->add( days => 1 ) ;
+}
+#if we want the first such weekday we're already there
+if ( $dateParts[ 2 ] == 1 ) {
+ say $dt->day ;
+}
+#otherwise , keep adding as many days as necessary to arrive at the n'th position
+else {
+ $dt->add( days => ( $dateParts[ 2 ] - 1 ) * 7 ) ;
+ if ( $dt->month != $dateParts[ 1 ] ) {#month rollover, the given weekday doesn't exist
+ say 0 ;
+ }
+ else {
+ say $dt->day ;
+ }
+}
diff --git a/challenge-237/ulrich-rieke/perl/ch-2.pl b/challenge-237/ulrich-rieke/perl/ch-2.pl
new file mode 100755
index 0000000000..23730279e4
--- /dev/null
+++ b/challenge-237/ulrich-rieke/perl/ch-2.pl
@@ -0,0 +1,25 @@
+#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+use Algorithm::Combinatorics qw ( permutations ) ;
+
+say "Enter some integers, separated by blanks!" ;
+my $line = <STDIN> ;
+chomp $line ;
+my @numbers = split( /\s/ , $line ) ;
+my $len = scalar( @numbers ) ;
+my $max_greatness = 0 ;
+my $iter = permutations( \@numbers ) ;
+while ( my $p = $iter->next ) {
+ my $current_greatness = 0 ;
+ for my $i ( 0..$len - 1 ) {
+ if ( $p->[ $i ] > $numbers[ $i ] ) {
+ $current_greatness++ ;
+ }
+ }
+ if ( $current_greatness > $max_greatness ) {
+ $max_greatness = $current_greatness ;
+ }
+}
+say $max_greatness ;
diff --git a/challenge-237/ulrich-rieke/raku/ch-1.raku b/challenge-237/ulrich-rieke/raku/ch-1.raku
new file mode 100755
index 0000000000..240c7b47e4
--- /dev/null
+++ b/challenge-237/ulrich-rieke/raku/ch-1.raku
@@ -0,0 +1,26 @@
+use v6 ;
+
+say "Please enter a year( positive integer ) , a month( integer from 1 to 12)," ;
+say " the index of a given weekday( integer from 1 to 5 ) , and a weekday( 1 to 7 )" ;
+my $line = $*IN.get ;
+my @dateparts = $line.words.map( {.Int} ) ;
+#construct a date for the first day in the given month of the given year
+my $d = Date.new( @dateparts[ 0 ] , @dateparts[ 1 ] , 1 ) ;
+#add a day until you reach the given weekday
+while ( $d.day-of-week != @dateparts[ 3 ] ) {
+ $d .= later( days => 1 ) ;
+}
+#if we want the day of the first given weekday we're already there
+if ( @dateparts[ 2 ] == 1 ) {
+ say $d.day ;
+}
+#otherwise, we add as many days as necessary to reach the n'th given weekday
+else {
+ $d .= later( days => ( @dateparts[ 2 ] - 1 ) * 7 ) ;
+ if ( $d.month != @dateparts[ 1 ] ) {#a month rollover occurred! we must output 0!
+ say 0 ;
+ }
+ else {
+ say $d.day ; #otherwise, we output the day
+ }
+}
diff --git a/challenge-237/ulrich-rieke/raku/ch-2.raku b/challenge-237/ulrich-rieke/raku/ch-2.raku
new file mode 100755
index 0000000000..c77b3b8894
--- /dev/null
+++ b/challenge-237/ulrich-rieke/raku/ch-2.raku
@@ -0,0 +1,20 @@
+use v6 ;
+
+say "Enter some integers, separated by spaces!" ;
+my $line = $*IN.get ;
+my @numbers = $line.words.map( {.Int} ) ;
+my $len = @numbers.elems ;
+my $max_greatness = 0 ;
+my @allPermus = @numbers.permutations ;
+for @allPermus -> $permu {
+ my $current_greatness = 0 ;
+ for (0..$len - 1) -> $pos {
+ if ( $permu[ $pos ] > @numbers[ $pos ] ) {
+ $current_greatness++ ;
+ }
+ }
+ if ( $current_greatness > $max_greatness ) {
+ $max_greatness = $current_greatness ;
+ }
+}
+say $max_greatness ;
diff --git a/challenge-237/ulrich-rieke/rust/ch-1.rs b/challenge-237/ulrich-rieke/rust/ch-1.rs
new file mode 100755
index 0000000000..cd48ee7762
--- /dev/null
+++ b/challenge-237/ulrich-rieke/rust/ch-1.rs
@@ -0,0 +1,33 @@
+use chrono::{NaiveDate , Weekday , Datelike} ;
+use std::io ;
+
+fn main() {
+ println!("Enter the year , the month , the number of given weekday and the weekday!");
+ let mut inline : String = String::new( ) ;
+ io::stdin( ).read_line( &mut inline ).unwrap( ) ;
+ let entered_line : &str = &*inline ;
+ let numbers : Vec<usize> = entered_line.split_whitespace( ).map( | s |
+ s.trim( ).parse::<usize>( ).unwrap( )).collect( ) ;
+ let y : i32 = numbers[0] as i32 ;
+ let m : u32 = numbers[1] as u32 ;
+ let num : u8 = numbers[2] as u8 ;
+ let wd : Weekday = match numbers[3] {
+ 1 => Weekday::Mon ,
+ 2 => Weekday::Tue ,
+ 3 => Weekday::Wed ,
+ 4 => Weekday::Thu ,
+ 5 => Weekday::Fri ,
+ 6 => Weekday::Sat ,
+ 7 => Weekday::Sun ,
+ _ => Weekday::Sun
+ } ;
+ if NaiveDate::from_weekday_of_month_opt( y , m ,
+ wd , num ).is_some( ) {
+ let day = NaiveDate::from_weekday_of_month_opt( y , m ,
+ wd , num ).unwrap( ).day( ) ;
+ println!("{}" , day ) ;
+ }
+ else {
+ println!("0") ;
+ }
+}
diff --git a/challenge-237/ulrich-rieke/rust/ch-2.rs b/challenge-237/ulrich-rieke/rust/ch-2.rs
new file mode 100755
index 0000000000..0060eb6123
--- /dev/null
+++ b/challenge-237/ulrich-rieke/rust/ch-2.rs
@@ -0,0 +1,27 @@
+use std::io ;
+use itertools::Itertools ;
+
+fn main() {
+ println!("Enter some 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( ) ;
+ let original_numbers : Vec<i32> = numbers.clone( ) ;
+ let len : usize = numbers.len( ) ;
+ let mut max_greatness : usize = 0 ;
+ let it = numbers.into_iter( ).permutations( len ) ;
+ for v in it {
+ let mut current_greatness : usize = 0 ;
+ for i in 0..len {
+ if v[ i ] > original_numbers[ i ] {
+ current_greatness += 1 ;
+ }
+ }
+ if current_greatness > max_greatness {
+ max_greatness = current_greatness ;
+ }
+ }
+ println!("{}" , max_greatness ) ;
+}
diff --git a/stats/pwc-challenge-229.json b/stats/pwc-challenge-229.json
index e7a03eac9e..bf66f9167b 100644
--- a/stats/pwc-challenge-229.json
+++ b/stats/pwc-challenge-229.json
@@ -1,27 +1,219 @@
{
- "xAxis" : {
- "type" : "category"
+ "chart" : {
+ "type" : "column"
},
"title" : {
"text" : "The Weekly Challenge - 229"
},
"plotOptions" : {
"series" : {
+ "borderWidth" : 0,
"dataLabels" : {
- "format" : "{point.y}",
- "enabled" : 1
- },
- "borderWidth" : 0
+ "enabled" : 1,
+ "format" : "{point.y}"
+ }
}
},
"subtitle" : {
- "text" : "[Champions: 38] Last updated at 2023-10-01 17:12:10 GMT"
+ "text" : "[Champions: 37] Last updated at 2023-10-08 18:44:26 GMT"
},
+ "series" : [
+ {
+ "colorByPoint" : 1,
+ "data" : [
+ {
+ "y" : 5,
+ "name" : "Ali Moradi",
+ "drilldown" : "Ali Moradi"
+ },
+ {
+ "name" : "Andreas Voegele",
+ "y" : 3,
+ "drilldown" : "Andreas Voegele"
+ },
+ {
+ "drilldown" : "Arne Sommer",
+ "name" : "Arne Sommer",
+ "y" : 3
+ },
+ {
+ "drilldown" : "