# MostOccuringWeekdays Wolfram Challenge [closed]

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,
Saturday};
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

However when I ask WolframAlpha to solve the problem for me I get the following:

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.

## closed as unclear what you're asking by m_goldberg, b3m2a1, LCarvalho, Öskå, CoolwaterNov 16 '18 at 9:12

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• 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. – m_goldberg Nov 8 '18 at 5:08
• 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. – C. Fuhrman Nov 8 '18 at 5:43
• 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. – m_goldberg Nov 8 '18 at 6:11
• 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. – WReach Nov 8 '18 at 15:02
• OK thank you -- that was what I was after (validation that I had the correct answer). Thank you @WReach. – C. Fuhrman Nov 9 '18 at 1:48

Also

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}]


53

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..

First/@Select[Tally[DayName/@DayRange[{y=year,1,1},{y,12,31}]],#[[2]]==53&]


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