aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-227/perlboy1967/perl/ch1.pl34
1 files changed, 34 insertions, 0 deletions
diff --git a/challenge-227/perlboy1967/perl/ch1.pl b/challenge-227/perlboy1967/perl/ch1.pl
new file mode 100755
index 0000000000..6c907f8d3b
--- /dev/null
+++ b/challenge-227/perlboy1967/perl/ch1.pl
@@ -0,0 +1,34 @@
+#!/bin/perl
+
+=pod
+
+The Weekly Challenge - 227
+- https://theweeklychallenge.org/blog/perl-weekly-challenge-227
+
+Author: Niels 'PerlBoy' van Dijke
+
+Task 1: Friday 13th
+Submitted by: Peter Campbell Smith
+
+You are given a year number in the range 1753 to 9999.
+
+Write a script to find out how many dates in the year are Friday 13th, assume
+that the current Gregorian calendar applies.
+
+=cut
+
+use v5.16;
+
+use common::sense;
+
+use Test::More;
+
+use DateTime;
+
+sub nFriday13th ($) {
+ scalar grep { DateTime->new(year => $_[0], month => $_, day => 13)->day_of_week == 5 } (1 .. 12);
+}
+
+is(nFriday13th(2023),2);
+
+done_testing;