I am working this challenge from Wolfram Challenge. I believe that I have solved the problem with the following code (note it is not very efficient - I am new to Mathematica!)

MostOccurringWeekday[year_Integer] := Module[{days, t, i},
  days = {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, 
  t = Table[
    Length[DayRange[DateObject[{year, 1, 1}], 
      DateObject[{year, 12, 31}], i]], {i, days}];
  i = Position[t, Max[t]];
  Extract[days, i]]

I am getting my answer rejected stating that the most occurring days in 2100 are Friday and Saturday

Challenge Rejection

However when I ask WolframAlpha to solve the problem for me I get the following: Fridays in 2100 Saturdays in 2100

So WolframAlpha states that there are 53 Fridays and 52 Saturdays in 2100, which would mean that the correct output for my function would be Friday, no? 157 people have solved this problem so I don't doubt Wolfram's rejecting of my function but am thoroughly confused why WolframAlpha supports my answer but Wolfram Challenge does not.

  • $\begingroup$ I don't see a question in your post that we could reasonably be expected answer. Question on how Wolfram|Alpha works are explicitly excluded from consideration on this site. $\endgroup$ – m_goldberg Nov 8 '18 at 5:08
  • $\begingroup$ I am not asking how WolframAlpha works - I include these screenshots to show reasoning for my confusion, which I stated was the reasoning for my written function being wrong (as shown in image 1) when calculating the most weekdays in the year 2100. I believe I was specific in stating my confusion was with my Mathematica function and only provide WolframAlpha screenshots to establish a basis for my confusion. $\endgroup$ – C. Fuhrman Nov 8 '18 at 5:43
  • $\begingroup$ OK, but if your question isn't about the Wolfram|Alpha answer, then what exactly is it? I may be being dense, but I honestly don't see any other question in your post. $\endgroup$ – m_goldberg Nov 8 '18 at 6:11
  • $\begingroup$ The answer given on the Wolfram Challenge site is incorrect, yours is correct. I suspect that the Challenge solution has made the common mistake of thinking that 2100 is a leap year. $\endgroup$ – WReach Nov 8 '18 at 15:02
  • $\begingroup$ OK thank you -- that was what I was after (validation that I had the correct answer). Thank you @WReach. $\endgroup$ – C. Fuhrman Nov 9 '18 at 1:48


Counts @ DayName @ DayRange[{2100, 1, 1}, {2100, 12, 31}]

<|Friday -> 53, Saturday -> 52, Sunday -> 52, Monday -> 52, Tuesday -> 52, Wednesday -> 52, Thursday -> 52|>

MaximalBy[Identity] @ Counts @ DayName@DayRange[{2100, 1, 1}, {2100, 12, 31}] 

<|Friday -> 53|>

Max @ Counts @ DayName @ DayRange[{2100, 1, 1}, {2100, 12, 31}]  


|improve this answer|||||

I will not answer about WolframAlpha, but I'll show you an easier way to do this in Mathematica

year = 2100;
Tally[DateString[#, "DayName"] & /@ 
DayRange[DateObject[{year, 1, 1}], DateObject[{year, 12, 31}]]]   

{{"Friday", 53}, {"Saturday", 52}, {"Sunday", 52}, {"Monday", 52}, {"Tuesday", 52}, {"Wednesday", 52}, {"Thursday", 52}}

and now you can easily peak the results that you want

this code passed the test..

|improve this answer|||||

It was decided that there was an error in Wolfram Challenge's answer to this question. Therefore my answer, although suboptimal, is correct.

|improve this answer|||||

Not the answer you're looking for? Browse other questions tagged or ask your own question.