Димитър обнови решението на 08.03.2015 17:46 (преди над 9 години)
+def interpret_western_sign(day, month):
+ signs = {
+ ((1, 1), (1, 20)): 'capricorn',
+ ((1, 21), (2, 18)): 'aquarius',
+ ((2, 19), (3, 20)): 'pisces',
+ ((3, 21), (4, 20)): 'aries',
+ ((4, 21), (5, 20)): 'taurus',
+ ((5, 21), (6, 20)): 'gemini',
+ ((6, 21), (7, 22)): 'cancer',
+ ((7, 23), (8, 22)): 'leo',
+ ((8, 23), (9, 22)): 'virgo',
+ ((9, 23), (10, 22)): 'libra',
+ ((10, 23), (11, 21)): 'scorpio',
+ ((11, 22), (12, 21)): 'sagittarius',
+ ((12, 22), (12, 31)): 'capricorn',
+ }
+
+ for sign in signs:
+ if sign[0] <= (month, day) <= sign[1]:
+ return signs[sign]
+
+
+def interpret_chinese_sign(year):
+ signs = {
+ 1900: 'rat',
+ 1901: 'ox',
+ 1902: 'tiger',
+ 1903: 'rabbit',
+ 1904: 'dragon',
+ 1905: 'snake',
+ 1906: 'horse',
+ 1907: 'sheep',
+ 1908: 'monkey',
+ 1909: 'rooster',
+ 1910: 'dog',
+ 1911: 'pig',
+ }
+
+ return signs[1900 + ((year - 1900) % 12)]
+
+
+def interpret_both_signs(day, month, year):
+ return(interpret_western_sign(day, month), interpret_chinese_sign(year))