Last active
August 29, 2015 14:03
-
-
Save gonter/dd842c99205d1c201393 to your computer and use it in GitHub Desktop.
August mit 5 Freitagen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
=head1 NOTE | |
Keine Ahnung, wer die Geschichte aufgebracht hat, dass nur alle 823 Jahre | |
ein August mit 5 Freitagen vorkommen soll, aber das ist freilich Unsinn. | |
Das kommt im Durchschnitt alle 7 Jahre vor, wenn wer nachrechnen mag... | |
=cut | |
use strict; | |
use Data::Dumper; | |
$Data::Dumper::Indent= 1; | |
# my ($start_year, $end_year)= (1963, 2063); | |
my ($start_year, $end_year)= (1583, 9999); | |
my $month= 8; | |
my $verbose= 0; | |
for (my $year= $start_year; $year <= $end_year; $year++) | |
{ | |
my $matches= check_year ($year, $month); | |
printf ("%4d-%02d\n", $year, $month) if ($matches); | |
} | |
sub check_year | |
{ | |
my $year= shift; | |
my $month= shift; | |
my @days= split (/\n/, `ncal -M $month $year`); | |
chop (@days); | |
# print "Days: ", Dumper (\@days); | |
my $l5= $days[5]; | |
my $matches= 0; | |
if ($l5 eq 'Fr 1 8 15 22 29 ') | |
{ | |
$matches= 1; | |
print join ("\n", @days), "\n" if ($verbose); | |
} | |
return $matches; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment