diff options
| -rwxr-xr-x | challenge-019/ruben-westerberg/perl5/ch-1.pl | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/challenge-019/ruben-westerberg/perl5/ch-1.pl b/challenge-019/ruben-westerberg/perl5/ch-1.pl new file mode 100755 index 0000000000..d41bef8ed5 --- /dev/null +++ b/challenge-019/ruben-westerberg/perl5/ch-1.pl @@ -0,0 +1,21 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Time::Piece; +use Time::Seconds; +use List::Util qw<any>; +use v5.26; + +my $s= Time::Piece->strptime("1900","%Y"); +my $e= Time::Piece->strptime("2019","%Y"); +#Find the months with 5 weekends (5 fridays, 5 saturdays and 5 sundays). +#this is only possible when +# --month has 31 days +# --must start with a Friday +# +# Search by day as only one day will ever match the start of a month + +while ($s <= $e) { + $s+=ONE_DAY; + print $s->strftime("%Y %B"), "\n" if ($s->mday==1) && ($s->day_of_week==5) && any {$s->mon == $_ } (1,3,5,7,8,10,12) +} |
