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

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

Към профила на Елена Денева

Резултати

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

Код

ZODIAC_BOUNDARIES = [None, 21, 19, 21, 21, 21, 21, 23, 23, 23, 23, 22, 22, 21]
ZODIAC_SIGNS = [
None, "capricorn", "aquarius", "pisces", "aries",
"taurus", "gemini", "cancer", "leo", "virgo",
"libra", "scorpio", "sagittarius", "capricorn",
]
CHINESE_SIGNS = [
"monkey", "rooster", "dog", "pig", "rat", "ox",
"tiger", "rabbit", "dragon", "snake", "horse", "sheep",
]
def interpret_western_sign(day, month):
if day < ZODIAC_BOUNDARIES[month]:
return ZODIAC_SIGNS[month]
return ZODIAC_SIGNS[month + 1]
def interpret_chinese_sign(year):
return CHINESE_SIGNS[year % 12]
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))

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

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

OK

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

Елена обнови решението на 05.03.2015 18:57 (преди около 9 години)

+def interpret_western_sign(day, month):
+ zodiac_boundaries = [
+ -1, 21, 19, 21, 21,
+ 21, 21, 23, 23, 23,
+ 23, 22, 22, 21,
+ ]
+ zodiac_names = [
+ "", "capricorn", "aquarius", "pisces", "aries",
+ "taurus", "gemini", "cancer", "leo", "virgo",
+ "libra", "scorpio", "sagittarius", "capricorn",
+ ]
+ if day < zodiac_boundaries[month]:
+ return zodiac_names[month]
+ return zodiac_names[month + 1]
+
+
+def interpret_chinese_sign(year):
+ chinese_signs_names = [
+ "monkey", "rooster", "dog", "pig", "rat", "ox",
+ "tiger", "rabbit", "dragon", "snake", "horse", "sheep",
+ ]
+ return chinese_signs_names[year % 12]
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Елена обнови решението на 07.03.2015 05:34 (преди около 9 години)

-def interpret_western_sign(day, month):
- zodiac_boundaries = [
- -1, 21, 19, 21, 21,
- 21, 21, 23, 23, 23,
- 23, 22, 22, 21,
- ]
- zodiac_names = [
- "", "capricorn", "aquarius", "pisces", "aries",
+ZODIAC_BOUNDARIES = [None, 21, 19, 21, 21, 21, 21, 23, 23, 23, 23, 22, 22, 21]
+ZODIAC_SIGNS = [
+ None, "capricorn", "aquarius", "pisces", "aries",
"taurus", "gemini", "cancer", "leo", "virgo",
"libra", "scorpio", "sagittarius", "capricorn",
- ]
- if day < zodiac_boundaries[month]:
- return zodiac_names[month]
- return zodiac_names[month + 1]
+]
+CHINESE_SIGNS = [
+ "monkey", "rooster", "dog", "pig", "rat", "ox",
+ "tiger", "rabbit", "dragon", "snake", "horse", "sheep",
+]
+
+def interpret_western_sign(day, month):
+ if day < ZODIAC_BOUNDARIES[month]:
+ return ZODIAC_SIGNS[month]
+ return ZODIAC_SIGNS[month + 1]
+
def interpret_chinese_sign(year):
- chinese_signs_names = [
- "monkey", "rooster", "dog", "pig", "rat", "ox",
- "tiger", "rabbit", "dragon", "snake", "horse", "sheep",
- ]
- return chinese_signs_names[year % 12]
+ return CHINESE_SIGNS[year % 12]
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))