Skip to content

Instantly share code, notes, and snippets.

@TomDeBeauchamp
Created June 26, 2013 23:39
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 TomDeBeauchamp/5872762 to your computer and use it in GitHub Desktop.
Save TomDeBeauchamp/5872762 to your computer and use it in GitHub Desktop.
MIT 6.189 from the first problem set, the optional Zeller Algorithm
def zeller(A,B,C,D):
if A == 1 or A == 2:
A+=10
C-=1
else:
A-=2
W = (13*A-1) / 5
X = C / 4
Y = D / 4
Z = W + X + Y + B + C - 2*D
R = Z % 7
if R < 0:
R += 7
if R == 0:
return "Sunday"
if R == 1:
return "Monday"
if R == 2:
return "Tuesday"
if R == 3:
return "Wednesday"
if R == 4:
return "Thursday"
if R == 5:
return "Friday"
if R == 6:
return "Saturday"
A = int(raw_input("what month are we talking? "))
B = int(raw_input("what is the day of the month? "))
C = int(raw_input("what year? Just the last two digits "))
D = int(raw_input("what century? "))
print zeller(A,B,C,D)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment