Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Bruteforce solution in Uncategorized category for The Most Frequent Weekdays by Moff
from datetime import date, timedelta
from collections import defaultdict
def most_frequent_days(year):
td = timedelta(days=1)
d1 = date(year=year, month=1, day=1)
d2 = date(year=year + 1, month=1, day=1)
res = defaultdict(int)
while d1 < d2:
res[d1.strftime('%A')] += 1
d1 += td
max_v = max(res.values())
res = [k for k, v in res.items() if v == max_v]
# ugly fix
order = 'Monday Tuesday Wednesday Thursday Friday Saturday Sunday'.split()
res.sort(key=lambda x: order.index(x))
return res
March 23, 2016