Last active
July 24, 2016 04:42
-
-
Save yue82/6ff0e563d42b5a6c06dd2b63cfa59901 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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