in reply to Re: How preparing the weekly shift roster led to a fascinating discovery...
in thread How preparing the weekly shift roster led to a fascinating discovery...
However, I should point out that in order to see the full pattern that emerges it is necessary to test for ~400 years. This makes sense of course, given the (Gregorian Calendar) Leap Year Rules.
The output from the following (modified from my original) code gives an indication of the pattern:
#!/usr/bin/perl -l use strict; use warnings; use Date::Calc qw/Days_in_Month Day_of_Week/; my @days_of_week = qw/Mon Tue Wed Thu Fri Sat Sun/; my $cnt; my @cnt; for my $year (1 .. 2500) { my %days_of_month; for my $month_of_year(1 .. 12) { for my $day_of_month(1 .. Days_in_Month($year,$month_of_year)) + { my $dow = Day_of_Week($year,$month_of_year,$day_of_month); $days_of_month{$day_of_month}{$days_of_week[--$dow]}++; } } for my $day_of_month (sort {$a <=> $b} keys %days_of_month) { next if scalar keys %{$days_of_month{$day_of_month}} == 7; my @missing_days; for (@days_of_week) { push (@missing_days, $_) if !defined $days_of_month{$day_o +f_month}{$_}; } $cnt++; if ($missing_days[0] eq 'Sun') { push @cnt, $cnt; if ($cnt == 11) { print "$year:@cnt"; @cnt = (); } $cnt = 0; } } }
However, it's not so much the pattern that I found interesting - but the fact that every year it's _always_ the same day of the month (31st) that doesn't occur on every day of the week.
Cheers,
Darren :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How preparing the weekly shift roster led to a fascinating discovery...
by Jenda (Abbot) on Dec 14, 2007 at 18:33 UTC |