Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First : Probably not the answer the question asks for solution in Clear category for The Most Frequent Weekdays by keromage
import calendar
from datetime import datetime
def most_frequent_days(a):
"""
There are 365 days a year in a normal year. January 1st and
December 31st are the same day of the week (365 % 7 = 1),
which is the most common day of the year. In leap years,
January 1st and December 30th are the same day of the week
(365 % 7 = 2), and that day and December 31st are the most
common days of the week.
"""
lists = []
last2days = (30, 31)
if calendar.isleap(a):
for i in last2days:
lists.append(datetime(a, 12, i).strftime('%A'))
if lists == ['Sunday', 'Monday']:
lists = ['Monday', 'Sunday'] # Week starts with Monday.
else:
lists.append(datetime(a, 12, 31).strftime('%A'))
return lists
if __name__ == '__main__':
print("Example:")
print(most_frequent_days(1084))
# These "asserts" are used for self-checking and not for an auto-testing
assert most_frequent_days(1084) == ['Tuesday', 'Wednesday']
assert most_frequent_days(1167) == ['Sunday']
assert most_frequent_days(1216) == ['Friday', 'Saturday']
assert most_frequent_days(1492) == ['Friday', 'Saturday']
assert most_frequent_days(1770) == ['Monday']
assert most_frequent_days(1785) == ['Saturday']
assert most_frequent_days(212) == ['Wednesday', 'Thursday']
assert most_frequent_days(1) == ['Monday']
assert most_frequent_days(2135) == ['Saturday']
assert most_frequent_days(3043) == ['Sunday']
assert most_frequent_days(2001) == ['Monday']
assert most_frequent_days(3150) == ['Sunday']
assert most_frequent_days(3230) == ['Tuesday']
assert most_frequent_days(328) == ['Monday', 'Sunday']
assert most_frequent_days(2016) == ['Friday', 'Saturday']
print("Coding complete? Click 'Check' to earn cool rewards!")
Oct. 25, 2020