Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
k solution in Clear category for The Most Frequent Weekdays by magda_kudrycka
from datetime import date
def most_frequent_days(year):
dni = ['Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday']
leap = year % 400 == 0 or (year % 100 != 0 and year % 4 == 0)
first = date(year, 1, 1).weekday()
nr = [first]
if leap:
nr.append((first + 1) % 7)
nr.sort()
if leap:
return [dni[nr[0]],dni[nr[1]]]
else:
return [dni[nr[0]]]
Nov. 4, 2016