Радослав обнови решението на 10.03.2015 22:37 (преди над 9 години)
+from bisect import bisect
+
+WESTERN_SIGNS = [(1, 20, "Capricorn"), (2, 18, "Aquarius"), (3, 20, "Pisces"),
+ (4, 20, "Aries"), (5, 21, "Taurus"), (6, 21, "Gemini"),
+ (7, 22, "Cancer"), (8, 23, "Leo"),
+ (9, 23, "Virgo"), (10, 23, "Libra"), (11, 22, "Scorpio"),
+ (12, 22, "Sagittarius"),
+ (12, 31, "Capricorn")]
+
+CHINESE_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")]
+
+
+def interpret_western_sign(day, month):
+ if (month in [1, 3, 5, 7, 8, 10, 12] and 0 < day < 32 or
+ month in [4, 6, 9, 11] and 0 < day < 31 or
+ month == 2 and 0 < day < 29):
+ return WESTERN_SIGNS[bisect(WESTERN_SIGNS, (month, day))][2]
+ else:
+ raise Exception("Wrong date")
+
+
+def interpret_chinese_sign(year):
+ return CHINESE_SIGNS[(year - CHINESE_SIGNS[0][0]) % 12][1]
+
+
+def interpret_both_signs(day, month, year):
+ western_sign = interpret_western_sign(day, month)
+ chinese_sign = interpret_chinese_sign(year)
+ return western_sign, chinese_sign