This problem is fairly easy to solve if you know about Conway’s “Doomsday Rule” for converting dates to days of the week in your head.

Following Conway’s Doomsday rule, the last day of Feb is always a doomsday. So then we have do calculate the distribution of doomsdays for the 400-year gregorian cycle. This is done nicely with the code above; I just counted from Wikipedia’s list of Doomsdays, which conveniently highlights leap-years.

Mon 15
Tue 13
Wed 15
Thu 13
Fri 14
Sat 14
Sun 13

Total 97