Решение на Астрологични забави от Иван Георгиев

Обратно към всички решения

Към профила на Иван Георгиев

Резултати

  • 10 точки от тестове
  • 0 бонус точки
  • 10 точки общо
  • 6 успешни тест(а)
  • 0 неуспешни тест(а)

Код

SIGNS = ["capricorn", "aquarius", "pisces", "aries", "taurus", "gemini",
"cancer", "leo", "virgo", "libra", "scorpio", "sagittarius"]
RANGES = {1: 21, 2: 19, 3: 21, 4: 21, 5: 21, 6: 21, 7: 23, 8: 23, 9: 23,
10: 23, 11: 22, 12: 22}
ANIMALS = ["rat", "ox", "tiger", "rabbit", "dragon", "snake", "horse",
"sheep", "monkey", "rooster", "dog", "pig"]
CHINESE_SIGNS = dict(zip(range(1900, 1912), ANIMALS))
def interpret_western_sign(day, month):
return SIGNS[month % 12 - (day < RANGES[month])]
def interpret_chinese_sign(year):
for chinese_year in CHINESE_SIGNS.keys():
if not (chinese_year - year) % 12:
return CHINESE_SIGNS[chinese_year]
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Лог от изпълнението

......
----------------------------------------------------------------------
Ran 6 tests in 0.006s

OK

История (1 версия и 0 коментара)

Иван обнови решението на 07.03.2015 12:13 (преди около 9 години)

+SIGNS = ["capricorn", "aquarius", "pisces", "aries", "taurus", "gemini",
+ "cancer", "leo", "virgo", "libra", "scorpio", "sagittarius"]
+
+RANGES = {1: 21, 2: 19, 3: 21, 4: 21, 5: 21, 6: 21, 7: 23, 8: 23, 9: 23,
+ 10: 23, 11: 22, 12: 22}
+
+ANIMALS = ["rat", "ox", "tiger", "rabbit", "dragon", "snake", "horse",
+ "sheep", "monkey", "rooster", "dog", "pig"]
+
+CHINESE_SIGNS = dict(zip(range(1900, 1912), ANIMALS))
+
+
+def interpret_western_sign(day, month):
+ return SIGNS[month % 12 - (day < RANGES[month])]
+
+
+def interpret_chinese_sign(year):
+ for chinese_year in CHINESE_SIGNS.keys():
+ if not (chinese_year - year) % 12:
+ return CHINESE_SIGNS[chinese_year]
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))