diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2023-07-31 01:12:33 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-31 01:12:33 +0100 |
| commit | 091aab3405809252ef062e18eaf27dc3fc9202dc (patch) | |
| tree | 2231efb21364cb0dff486e83454a67e3aec9ce3c | |
| parent | 50cd11f931f4dda407ad6de759f02fb86bac4206 (diff) | |
| parent | 577b5a21015398776fa6f83a9bf75efa8672a598 (diff) | |
| download | perlweeklychallenge-club-091aab3405809252ef062e18eaf27dc3fc9202dc.tar.gz perlweeklychallenge-club-091aab3405809252ef062e18eaf27dc3fc9202dc.tar.bz2 perlweeklychallenge-club-091aab3405809252ef062e18eaf27dc3fc9202dc.zip | |
Merge pull request #8468 from PerlBoy1967/branch-for-challenge-227
w227 - Task 1
| -rwxr-xr-x | challenge-227/perlboy1967/perl/ch1.pl | 34 |
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; |
