Skip to content

Instantly share code, notes, and snippets.

@yue82
Last active July 24, 2016 04:42
Show Gist options
  • Save yue82/6ff0e563d42b5a6c06dd2b63cfa59901 to your computer and use it in GitHub Desktop.
Save yue82/6ff0e563d42b5a6c06dd2b63cfa59901 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from datetime import date
def main(filename):
months = {'January': 1,
'February': 2,
'March': 3,
'April': 4,
'May': 5,
'June': 6,
'July': 7,
'August': 8,
'September': 9,
'October': 10,
'November': 11,
'December': 12
}
count = 0
with open(filename, 'r') as f:
for line in f:
month = months[line.split(' ')[0]]
day = int(line.split(' ')[1][:-1])
year = int(line.split(' ')[2])
if month == 2 and day == 29:
continue
next_weekday = date(year+1, month, day).weekday()
if next_weekday == 4:
count += 1
print count
if __name__ == '__main__':
main('date.txt')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment