Skip to content

Instantly share code, notes, and snippets.



Last active Dec 18, 2015
What would you like to do?
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:
#!/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