aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-019/jo-37/perl/ch-1.pl27
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-019/jo-37/perl/ch-1.pl b/challenge-019/jo-37/perl/ch-1.pl
new file mode 100755
index 0000000000..b64aa0549b
--- /dev/null
+++ b/challenge-019/jo-37/perl/ch-1.pl
@@ -0,0 +1,27 @@
+#!/usr/bin/perl -s
+
+use v5.16;
+use warnings;
+use Date::Manip::Recur;
+
+main: {
+ # A month with five Fridays and five Sundays has five Saturdays,
+ # too.
+
+ # Find all months having five Fridays.
+ my @fridays = map $_->printf('%Y/%m'),
+ Date::Manip::Recur->new('5th Friday of every month',
+ undef, 1900, 2020)->dates;
+ # Find all months having five Sundays.
+ my @sundays = map $_->printf('%Y/%m'),
+ Date::Manip::Recur->new('5th Sunday of every month',
+ undef, 1900, 2020)->dates;
+
+ # Build a hash having the months with five Fridays as keys and
+ # values.
+ my %fridays;
+ @fridays{@fridays} = @fridays;
+ # Find the intersection between months with five Fridays and five
+ # Sundays.
+ say for grep defined, @fridays{@sundays};
+}