import time as t
start = t.perf_counter()
def leap_year(year):
if year % 4:
return 0
else:
if year % 100:
return 1
elif year % 400:
return 0
else:
return 1
res, sundays = 1, 0
dates, leap_years = [], []
for i in range(1901, 2001):
is_leap = leap_year(i)
month_day = [3, 0 + (1 * is_leap), 3, 2, 3, 2, 3, 3, 2, 3, 2, 3]
count_month = 1
for month in month_day:
count_month += 1
res += month
if not ((res + 1) % 7):
sundays += 1
if count_month < 13:
date = "%s.%s" % (i, count_month)
dates.append(date)
else:
date = "%s.%s" % (i + 1, 1)
dates.append(date)
for i in dates:
print(i)
print(sundays)
print("It costs %f s" % (t.perf_counter() - start))
|