Created
June 26, 2013 23:39
-
-
Save TomDeBeauchamp/5872762 to your computer and use it in GitHub Desktop.
MIT 6.189 from the first problem set, the optional Zeller Algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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