blob: f018e05871ba31ba8b71b8c2e573f153ffd735a6 (
plain)
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
|
def month_days(index, leap_year):
if index == 2:
if leap_year:
return 29
return 28
if index in [4, 6, 9, 11]:
return 30
return 31
def is_leap_year(year):
if str(year)[2:] == '00' and year % 400 != 0:
return False
if year % 4 == 0:
return True
return False
def next_day(current):
if current == 7:
return 1
return current + 1
months = [x for x in range(1, 13)]
day = 1
sundays_counter = 0
for year in range(1900, 2001):
for month in months:
for d in range(month_days(month, is_leap_year(year))):
if day == 7 and d == 0 and year >= 1901:
sundays_counter += 1
day = next_day(day)
print(sundays_counter)
|