I am new to Mathematica and for fun am trying some of the challenges. The one I am working on now is:

Write a function MostOccurringWeekday that takes an integer representing a year as input and returns a list of the most-occurring weekdays throughout that year.

I'm not sure where to start? I assume I'll have to do a loop from 1/1/[YEAR] to 12/31/[YEAR] and count each weekday.

This is my attempt at getting a date:

year = 1998
Interpreter["Date"][StringForm["1/1/``", year]]

But this results in an error.

If anyone could give some pointers, I'd greatly appreciate it.


  • 1
    $\begingroup$ Lookup DayCount $\endgroup$ – Carl Woll Apr 25 at 14:48
  • $\begingroup$ I assume I'll have to do a loop from .... Whoaaa, slow down there. In a 365-day year there are 53 occurrences of the day on which the year starts, 52 occurrences of each of the other days. Try something like DateString[{2018}, "DayName"] and work the rest out. $\endgroup$ – High Performance Mark Apr 25 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.