Skip to content

Instantly share code, notes, and snippets.

@iomz
Created April 12, 2012 13:28
Show Gist options
  • Save iomz/2367208 to your computer and use it in GitHub Desktop.
Save iomz/2367208 to your computer and use it in GitHub Desktop.
Jason's day
Months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
Days = [31,29,31,30,31,30,31,31,30,31,30,31]
DateDict = dict(zip(Months,Days))
WeekDayList = ["Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
weekinitializer = [0,0,0,0,0,0,0]
monthinitializer = [0,0,0,0,0,0,0,0,0,0,0,0]
Thirteens = dict(zip(WeekDayList, weekinitializer))
JasonCount = []
JasonMonthCount = dict(zip(Months, monthinitializer))
# 2012,1,1,Sunday
weekdayiter = 0
StartYear = 2012
EndYear = 3012
for year in range(StartYear, EndYear+1):
for month in Months:
for day in range(1, DateDict[month]+1):
if month == 'Feb' and day == 29 and year%4 != 0:
continue
if WeekDayList[weekdayiter] == 'Friday' and day == 13:
jasondate = "%d %s %d Fri" % (year, month, day)
# print jasondate
JasonCount.append(jasondate)
JasonMonthCount[month] += 1
if day == 13:
Thirteens[WeekDayList[weekdayiter]] += 1
if weekdayiter != 6:
weekdayiter += 1
else:
weekdayiter = 0
print "\n%s\n\tFrom %d to %d...\n%s\n" % (40*'#', StartYear, EndYear, 40*'#')
for day in WeekDayList:
print "%s 13th: %d counts" % (day, Thirteens[day])
print 40*'-'
print "Jason's Friday 13th comes %d times!" % len(JasonCount)
for month in Months:
print "Friday 13th appears in %s: %d times" % (month, JasonMonthCount[month])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment