Skip to content

Instantly share code, notes, and snippets.

@jpstroop
Last active December 18, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpstroop/5793245 to your computer and use it in GitHub Desktop.
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:
#!/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