Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Creative category for The Most Frequent Weekdays by Joachim99
import datetime
def most_frequent_days(year):
lista=[]
a=''
b=''
if(year%400==0):
y = datetime.datetime(year, 12, 30)
x = datetime.datetime(year, 12, 31)
a=y.strftime("%A")
b=x.strftime("%A")
elif(year%100==0):
x = datetime.datetime(year, 12, 31)
a=x.strftime("%A")
elif(year%4==0):
y = datetime.datetime(year, 12, 30)
x = datetime.datetime(year, 12, 31)
a=y.strftime("%A")
b=x.strftime("%A")
else:
x = datetime.datetime(year, 12, 31)
a=x.strftime("%A")
lista.append(a)
if(len(b)>0):
lista.append(b)
if(b=="Monday"):
lista.reverse()
print(lista)
return lista
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(328) == ['Monday' , 'Sunday'], "3rd example"
assert most_frequent_days(2909) == ['Tuesday'], "4th example"
Nov. 29, 2018
Comments: