Create a gist now

Instantly share code, notes, and snippets.

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