Станислав обнови решението на 06.03.2015 22:22 (преди над 9 години)
+def interpret_western_sign(day, month):
+ signs = {
+ 'aries': {3: 21, 4: 20},
+ 'taurus': {4: 21, 5: 20},
+ 'gemini': {5: 21, 6: 20},
+ 'cancer': {6: 21, 7: 22},
+ 'leo': {7: 23, 8: 22},
+ 'virgo': {8: 23, 9: 22},
+ 'libra': {9: 23, 10: 22},
+ 'scorpio': {10: 23, 11: 21},
+ 'sagittarius': {11: 22, 12: 21},
+ 'capricorn': {12: 22, 1: 20},
+ 'aquarius': {1: 21, 2: 18},
+ 'pisces': {2: 19, 3: 20}
+ }
+
+ for sign, period in signs.items():
+ if period.get(month, False):
+ previous_month = month - 1
+ next_month = month + 1
+
+ if next_month == 13:
+ next_month = 1
+
+ if previous_month == 0:
+ previous_month = 12
+
+ if period.get(previous_month, False) and day <= period.get(month, 0):
+ return sign
+ elif period.get(next_month, False) and day >= period.get(month, 32):
+ return 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'
+ }
+
+ while year > 1899:
+ sign = signs.get(year, False)
+ year -= 12
+
+ return sign
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))