-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem19.py
32 lines (27 loc) · 869 Bytes
/
problem19.py
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
def isLeapYear(n):
# if divisible by 400 for sure leap year
if n % 400 == 0:
return True
# otherwise if not on a century
elif not n % 100 == 0:
# if divisible by 4 true, otherwise false
return (n%4==0)
# otherwise false
return False
months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
sundayCount = 0
dayIndex = 1
for year in range(1901,2001):
leap = False
if year%4 == 0:
leap = isLeapYear(year)
for i in range(len(months)):
if i == 1 and leap:
print("%d is a leap year!" % year)
dayIndex = dayIndex + 29%7
else:
dayIndex = dayIndex + (months[i] % 7)
dayIndex = dayIndex % 7
if dayIndex == 6:
sundayCount = sundayCount + 1