-
Notifications
You must be signed in to change notification settings - Fork 0
/
19.py
51 lines (44 loc) · 899 Bytes
/
19.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def checkIfLeap(year) :
return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
def getNbDaysInMonth(month, year) :
if month == 0:
return 31;
elif month == 1:
if checkIfLeap(year):
return 29;
else:
return 28;
elif month == 2:
return 31;
elif month == 3:
return 30;
elif month == 4:
return 31;
elif month == 5:
return 30;
elif month == 6:
return 31;
elif month == 7:
return 31;
elif month == 8:
return 30;
elif month == 9:
return 31;
elif month == 10:
return 30;
elif month == 11:
return 31;
if __name__ == "__main__":
startingDay = 365 % 7;
sum = 0;
if startingDay == 6:
sum += 1
for year in range(1901, 2001):
for month in range(0, 12):
if month == 12 and year == 2001:
startingDay = 0
else:
startingDay = (getNbDaysInMonth(month, year) + startingDay) % 7
if startingDay == 6:
sum += 1
print (sum)