From e72a0d33e191a62a83d69c6d4252fa733192ca77 Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Thu, 16 Mar 2023 18:12:40 +0100 Subject: Challenge 019 task 1 --- challenge-019/jo-37/perl/ch-1.pl | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 challenge-019/jo-37/perl/ch-1.pl 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}; +} -- cgit