From 47eb0093a4c9fc544fb127d4446bd95ce4f04653 Mon Sep 17 00:00:00 2001 From: Dave Jacoby Date: Wed, 27 Jul 2022 19:10:33 -0400 Subject: jacoby 175 pt 1 --- challenge-175/dave-jacoby/perl/ch-1.pl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 challenge-175/dave-jacoby/perl/ch-1.pl diff --git a/challenge-175/dave-jacoby/perl/ch-1.pl b/challenge-175/dave-jacoby/perl/ch-1.pl new file mode 100644 index 0000000000..33ade5d6fe --- /dev/null +++ b/challenge-175/dave-jacoby/perl/ch-1.pl @@ -0,0 +1,28 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use experimental qw{ say postderef signatures state }; + +use DateTime; + +my $year = 2022; + +for my $month ( 1 .. 12 ) { + my $dt = DateTime->new( + year => $year, + month => $month, + day => 1, + time_zone => 'floating' + ); + $dt->add( days => 32 ); + + # Remember that days of week are 1-7, and 0 doesn't match + # this isn't crontab + while (1) { + $dt->subtract( days => 1 ); + next unless $dt->month == $month; + last if $dt->day_of_week == 7; + } + say $dt->ymd; +} -- cgit