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 Elater
import datetime
def ktory(dzien):
if dzien == 0: return "Monday"
elif dzien == 1: return "Tuesday"
elif dzien == 2: return "Wednesday"
elif dzien == 3: return "Thursday"
elif dzien == 4: return "Friday"
elif dzien == 5: return "Saturday"
else: return "Sunday"
def most_frequent_days(year):
days = []
p = datetime.date(year,1,1).weekday()
o = datetime.date(year,12,31).weekday()
if p == o:
days.append(ktory(p))
else:
if p > o:
days.append(ktory(o))
days.append(ktory(p))
else:
days.append(ktory(p))
days.append(ktory(o))
return days
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"
Nov. 27, 2016