Skip to content

Instantly share code, notes, and snippets.

@codemaniac
Last active December 22, 2015 13:58
Show Gist options
  • Save codemaniac/6482443 to your computer and use it in GitHub Desktop.
Save codemaniac/6482443 to your computer and use it in GitHub Desktop.
day = 1
month = 12
year = 1988
days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
days_in_months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
is_leap_year = lambda y : y % 4 == 0 and (y % 100 != 0 or y % 400 == 0)
leap_years = len([y for y in xrange(1, year) if is_leap_year(y)])
normal_years = year - 1 - leap_years
extra_days = ((leap_years * 2) + normal_years)
days_in_current_year = sum(days_in_months[:month-1]) + day
if is_leap_year(year):
days_in_current_year += 1
extra_days += days_in_current_year
extra_days = extra_days % 7
print days[extra_days]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment