Advertisement
Guest User

Zeller's Algorithm

a guest
Jun 21st, 2013
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. months = {"01":11, "02":12, "03":1, "04":2, "05":3, "06":4,
  2. "07":5, "08":6, "09":7, "10":8, "11":9, "12":10}
  3. days = {"1":"Monday", "2":"Tuesday","3":"Wednesday","4":"Thursday","5":"Friday","6":"Saturday","0":"Sunday"}
  4.  
  5. bMonth = input("Want to know the day of the week you were born?\n Enter a number for the month: MM ")
  6. bDay = input("Enter a number for the day: DD ")
  7. bYear = int(input("Enter the two digit year: (e.g. 70 for 1970) YY "))
  8. bCent = int(input("Enter the two digit century: (e.g. 19 for 1970) CC "))
  9. A = int(months[bMonth])
  10. B = int(bDay)
  11. if A == 11 or A == 12:
  12.     if bYear == 00:
  13.         bYear = 99
  14.         bCent = bCent - 1
  15.     else:
  16.         bYear = bYear - 1
  17. C = bYear
  18. D = bCent
  19.  
  20. W = int((13*A - 1) / 5)
  21. X = int(C / 4)
  22. Y = int(D / 4)
  23. Z = int(W + X + Y + B + C - 2*D)
  24. R = int((Z%7))
  25.  
  26. if (R < 0):
  27.     R = (R+7)%6
  28.  
  29. print ("You were born on a " + days[str(R)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement