Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Random fact: Between 25% and 33% of the population sneeze when exposed to light. solution in Clear category for The Most Frequent Weekdays by siebenschlaefer
import calendar
def most_frequent_days(year):
"""Return the most frequent days of the week in the given 'year'."""
weekdays = [calendar.weekday(year, 1, 1)]
if calendar.isleap(year):
weekdays.append(calendar.weekday(year, 1, 2))
return [calendar.day_name[i] for i in sorted(weekdays)]
def test_most_frequent_days():
assert most_frequent_days(2399) == ['Friday']
assert most_frequent_days(1152) == ['Tuesday', 'Wednesday']
assert most_frequent_days(56) == ['Saturday', 'Sunday']
assert most_frequent_days(2909) == ['Tuesday']
assert most_frequent_days(328) == ['Monday', 'Sunday']
if __name__ == '__main__':
test_most_frequent_days()
March 22, 2016
Comments: