Last active
December 18, 2015 13:58
-
-
Save jpstroop/5793245 to your computer and use it in GitHub Desktop.
My birthday sometimes falls on Father's Day and Abi's sometimes falls on Mother's Day. I was wondering if this would this ever happen in the same year. Here's the answer:
This file contains 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 | |
from datetime import date | |
def fday_on_jons_bday(year): | |
return [d for d in range(15,22) if date(year, 6, d).weekday() == 6][0] == 16 | |
def mday_on_abis_bday(year): | |
return [d for d in range(8,15) if date(year, 5, d).weekday() == 6][0] == 14 | |
j_years = filter(lambda d: fday_on_jons_bday(d), range(2007,2078)) # F's bday to J's birth year + 100 | |
a_years = filter(lambda d: mday_on_abis_bday(d), range(2007,2074)) # F's bday to A's birth year + 100 | |
print j_years | |
print a_years | |
print set(j_years).intersection(set(a_years)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment