Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Most Frequent Weekdays by kurosawa4434
from datetime import date
WEEK = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
def most_frequent_days(year):
leap_year = False
if not year % 4:
if not year % 400:
leap_year = True
else:
if year % 100:
leap_year = True
w = date(year, 1, 1).weekday()
w1 = WEEK[w]
w2 = WEEK[w + 1 if w + 1 < 7 else 0]
if leap_year:
if w == 6:
w1, w2 = w2, w1
return [w1, w2]
else:
return [w1]
July 21, 2016