Serving the Quantitative Finance Community

 
User avatar
alphaquantum
Topic Author
Posts: 0
Joined: January 9th, 2008, 11:24 pm

Fridays 13

December 9th, 2008, 3:43 pm

What is the maximum number of Fridays 13th in a year? ps: the problem is to find a short/elegant solution, rather than count them blindly.
Last edited by alphaquantum on December 8th, 2008, 11:00 pm, edited 1 time in total.
 
User avatar
wileysw
Posts: 7
Joined: December 9th, 2006, 6:13 pm

Fridays 13

December 9th, 2008, 7:03 pm

3. no elegant solution though, i peeked at a year calendar.btw, i also looked at several 2-year calendars. seems in a year starting from whichever date, and no matter whether leap year or not, it's always 3.
 
User avatar
alphaquantum
Topic Author
Posts: 0
Joined: January 9th, 2008, 11:24 pm

Fridays 13

December 9th, 2008, 9:52 pm

QuoteOriginally posted by: wileysw3. no elegant solution though, i peeked at a year calendar.btw, i also looked at several 2-year calendars. seems in a year starting from whichever date, and no matter whether leap year or not, it's always 3. You claim the max is 3 (2008 has 3). Still, why it is not possible to have 4, or 5?
Last edited by alphaquantum on December 8th, 2008, 11:00 pm, edited 1 time in total.
 
User avatar
MCarreira
Posts: 64
Joined: January 1st, 1970, 12:00 am

Fridays 13

December 9th, 2008, 10:22 pm

The maximum number of Fridays 13th in a year is 3.Define:Months = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};MonthsL = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};AccMonths = Prepend[Most[Accumulate[Months]], 0];AccMonthsL = Prepend[Most[Accumulate[MonthsL]], 0];f[x_] := Mod[x, 7];Map[f, Prepend[Most[Accumulate[Months]], 0]]{0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5}Map[f, Prepend[Most[Accumulate[MonthsL]], 0]]{0, 3, 4, 0, 2, 5, 0, 3, 6, 1, 4, 6}No number appears more than 3 times (3 for non-leap years and 0 for leap years), and therefore you can only have 3 matching sets of days/weekdays.
 
User avatar
wileysw
Posts: 7
Joined: December 9th, 2006, 6:13 pm

Fridays 13

December 10th, 2008, 1:24 am

lol, i did not know 2008 has 3 black fridays.i was looking at the first day of each month, and count how many of them fall on the same day. turns out 3 is the maximum. since 2008 is a leap year so i took a look at 2007 calendar, which is again 3.then i wondered what if you start from any date of the year and count a year. two cases: the span covers or does not cover feb.29th. again the maximum is 3.what is the elegant solution?
Last edited by wileysw on December 9th, 2008, 11:00 pm, edited 1 time in total.
 
User avatar
alphaquantum
Topic Author
Posts: 0
Joined: January 9th, 2008, 11:24 pm

Fridays 13

December 10th, 2008, 4:29 am

QuoteOriginally posted by: wileyswlol, i did not know 2008 has 3 black fridays.? OK, I thought you counted only the Fridays 13 but, as part of the solution, you have to find a year with 3 such Fridays, btw
 
User avatar
MCarreira
Posts: 64
Joined: January 1st, 1970, 12:00 am

Fridays 13

December 10th, 2008, 11:10 am

A few examples:Non-leap years: 1914, 1942, 1970, 1998, 2026, 2054, 2082 (months: Feb, Mar, Nov)Leap years: 1928, 1956, 1984, 2012, 2040, 2068, 2096 (months: Jan, Apr, Jul)
 
User avatar
vxs
Posts: 0
Joined: November 1st, 2008, 4:33 pm

Fridays 13

December 14th, 2008, 1:01 am

This is what MCarreira has coded I guess... don't know if what I've written classifies as "elegant" Obviously the differences in the 13ths of each month has to be a factor of 7. Now we see that 63 and 91 are factors of 7. For 63, this means the sum of days in 2 months needs to be 63, which is not possible (according to the Gregorian calender at least!). For four months, the nearest factor of 7 is 126, which is also not possible, and for 5 months nearest factor is 154 (which needs four 31 day months and is also not possible).But for 3 months, 91 is possible if three consecutive months have only 30,30 and 31 (not necessarily in that order) and leap years if Jan 13th is a Friday. So we see that in a leap year, if Jan 13th is a Friday, April and July will have Friday the 13ths, and there will not be any more Friday the 13ths for the rest of the year. So the max possible is 3, and similarly in a non-leap year