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 hypehr96
import datetime
import calendar
XD = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
def most_frequent_days(year):
ilosci = [0,0,0,0,0,0,0]
for i in [1,2,3,4,5,6,7,8,9,10,11,12]:
for x in range(1,calendar.monthrange(year,i)[1]+1):
dz = datetime.datetime(year, i, x, 0, 0, 0, 0).weekday()
ilosci[dz]+=1
maxD = max(ilosci)
out = []
k=0
dT = 0
for i in ilosci:
print(i)
if i==maxD:
out.append(XD[dT])
k+=1
dT+=1
print("--")
return out
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. 6, 2017