Created
August 8, 2013 14:02
-
-
Save zbstof/6184843 to your computer and use it in GitHub Desktop.
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
m1 = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] | |
m2 = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] | |
mon_sy = { | |
1: "January", 2: "February", 3: "March", 4: "April", 5: "May", 6: "June", | |
7: "July", 8: "August", 9: "September", 10: "October", 11: "November", | |
12: "December"} | |
leap = [year for year in range(1904, 2001, 4)] | |
def months(): | |
for year in range(1901, 2001): | |
if year in leap: | |
for i, month in enumerate(m2): | |
yield year, i, month | |
else: | |
for i, month in enumerate(m1): | |
yield year, i, month | |
day = sum(m1) % 7 | |
sundays = 0 | |
for year, mon, days in months(): | |
if day == 6: | |
sundays = sundays + 1 | |
print year, mon_sy[mon + 1] | |
day = day + days | |
day = day % 7 | |
print sundays |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment