Hi :)
I was asked recently if I could write a Perl program that
would find out when the next time Christmas day would
actually be on a Sunday.
I said "Maybe."
After thinking about it - very little thought actually -
I came up with a recursive `cal 12 $year` Unix/Perl
script where $year was the four digit year since 1900,
continuing thru 2100...
Then I just parse the output to see what day of
the week the 25th fell on... I came up with:
#!perl
for $year (1900 .. 2100) {
$data = `cal 12 $year`;
@month = split(/\n/, $data);
print "\nChristmas found on a
Sunday in $year" if ($month[6] =~ /^25\s.*$/);
}
__END__
Example of a valid matching month:
December 2016
S M Tu W Th F S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Is there a better Perl Golf way?
_Sx____________________
('> -Sx- IUDICIUM
//\ Have Computer -
v_/_ Will Hack...
print pack('c5',(41*2),sqrt(7056),(unpack('c',H)-2),oct(115),10);