aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Sommrey <28217714+jo-37@users.noreply.github.com>2023-03-16 18:12:40 +0100
committerJörg Sommrey <28217714+jo-37@users.noreply.github.com>2023-03-23 18:03:42 +0100
commite72a0d33e191a62a83d69c6d4252fa733192ca77 (patch)
treef91b4515ea34880ff2d1086f637aac0880aeef62
parent184d93d16b5835cc10dc3aefa14f7fbef06fc436 (diff)
downloadperlweeklychallenge-club-e72a0d33e191a62a83d69c6d4252fa733192ca77.tar.gz
perlweeklychallenge-club-e72a0d33e191a62a83d69c6d4252fa733192ca77.tar.bz2
perlweeklychallenge-club-e72a0d33e191a62a83d69c6d4252fa733192ca77.zip
Challenge 019 task 1
-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};
+}