Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Speedy category for The Most Frequent Weekdays by aquazul
from datetime import date
def most_frequent_days(year):
"""
List of most frequent days of the week in the given year
"""
name = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
return [name[i] for i in sorted(set([date(year, 1, 1).weekday(), date(year, 12, 31).weekday()]))]
if __name__ == '__main__':
# These "asserts" using only for self-checking and not necessary for auto-testing
assert most_frequent_days(2399) == ['Friday'], "1st example"
assert most_frequent_days(1152) == ['Tuesday', 'Wednesday'], "2nd example"
assert most_frequent_days(56) == ['Saturday', 'Sunday'], "3rd example"
assert most_frequent_days(2909) == ['Tuesday'], "4th example"
Jan. 23, 2017
Comments: