Решение на Астрологични забави от Михаела Сейменска

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

Към профила на Михаела Сейменска

Резултати

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

Код

WESTERN_SIGNS = {1: ["capricorn", "aquarius", 20],
2: ["aquarius", "pisces", 18], 3: ["pisces", "aries", 20],
4: ["aries", "taurus", 20], 5: ["taurus", "gemini", 20],
6: ["gemini", "cancer", 20], 7: ["cancer", "leo", 22],
8: ["leo", "virgo", 22], 9: ["virgo", "libra", 22],
10: ["libra", "scorpio", 22],
11: ["scorpio", "sagittarius", 21],
12: ["sagittarius", "capricorn", 21]}
CHINESE_SIGNS = {0: "monkey", 1: "rooster", 2: "dog", 3: "pig", 4: "rat",
5: "ox", 6: "tiger", 7: "rabbit", 8: "dragon", 9: "snake",
10: "horse", 11: "sheep"}
def interpret_western_sign(day, month):
western_sign = WESTERN_SIGNS.get(month)
if western_sign[2] >= day:
return western_sign[0]
else:
return western_sign[1]
def interpret_chinese_sign(year):
return CHINESE_SIGNS.get(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 версии и 1 коментар)

Михаела обнови решението на 10.03.2015 23:31 (преди над 9 години)

+def interpret_western_sign(day, month):
+ if month == 1:
+ if day <= 20:
+ return 'capricorn'
+ else:
+ return 'aquarius'
+ elif month == 2:
+ if day <= 18:
+ return 'aquarius'
+ else:
+ return 'pisces'
+ elif month == 3:
+ if day <= 20:
+ return 'pisces'
+ else:
+ return 'aries'
+ elif month == 4:
+ if day <= 20:
+ return 'aries'
+ else:
+ return 'taurus'
+ elif month == 5:
+ if day <= 20:
+ return 'taurus'
+ else:
+ return 'gemini'
+ elif month == 6:
+ if day <= 20:
+ return 'gemini'
+ else:
+ return 'cancer'
+ elif month == 7:
+ if day <= 22:
+ return 'cancer'
+ else:
+ return 'leo'
+ elif month == 8:
+ if day <= 22:
+ return 'leo'
+ else:
+ return 'virgo'
+ elif month == 9:
+ if day <= 22:
+ return 'virgo'
+ else:
+ return 'libra'
+ elif month == 10:
+ if day <= 22:
+ return 'libra'
+ else:
+ return 'scorpio'
+ elif month == 11:
+ if day <= 21:
+ return 'scorpio'
+ else:
+ return 'sagittarius'
+ elif month == 12:
+ if day <= 21:
+ return 'sagittarius'
+ else:
+ return 'capricorn'
+
+
+def interpret_chinese_sign(year):
+ if year % 12 == 1:
+ return "rooster"
+ elif year % 12 == 2:
+ return "dog"
+ elif year % 12 == 3:
+ return "pig"
+ elif year % 12 == 4:
+ return "rat"
+ elif year % 12 == 5:
+ return "ox"
+ elif year % 12 == 6:
+ return "tiger"
+ elif year % 12 == 7:
+ return "rabbit"
+ elif year % 12 == 8:
+ return "dragon"
+ elif year % 12 == 9:
+ return "snake"
+ elif year % 12 == 10:
+ return "horse"
+ elif year % 12 == 11:
+ return "sheep"
+ elif year % 12 == 0:
+ return "monkey"
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Михаела обнови решението на 11.03.2015 11:48 (преди над 9 години)

+WESTERN_SIGNS = {1: ["capricorn", "aquarius", 20],
+ 2: ["aquarius", "pisces", 18], 3: ["pisces", "aries", 20],
+ 4: ["aries", "taurus", 20], 5: ["taurus", "gemini", 20],
+ 6: ["gemini", "cancer", 20], 7: ["cancer", "leo", 22],
+ 8: ["leo", "virgo", 22], 9: ["virgo", "libra", 22],
+ 10: ["libra", "scorpio", 22],
+ 11: ["scorpio", "sagittarius", 21],
+ 12: ["sagittarius", "capricorn", 21]}
+
+CHINESE_SIGNS = {0: "monkey", 1: "rooster", 2: "dog", 3: "pig", 4: "rat",
+ 5: "ox", 6: "tiger", 7: "rabbit", 8: "dragon", 9: "snake",
+ 10: "horse", 11: "sheep"}
+
+
def interpret_western_sign(day, month):
- if month == 1:
- if day <= 20:
- return 'capricorn'
- else:
- return 'aquarius'
- elif month == 2:
- if day <= 18:
- return 'aquarius'
- else:
- return 'pisces'
- elif month == 3:
- if day <= 20:
- return 'pisces'
- else:
- return 'aries'
- elif month == 4:
- if day <= 20:
- return 'aries'
- else:
- return 'taurus'
- elif month == 5:
- if day <= 20:
- return 'taurus'
- else:
- return 'gemini'
- elif month == 6:
- if day <= 20:
- return 'gemini'
- else:
- return 'cancer'
- elif month == 7:
- if day <= 22:
- return 'cancer'
- else:
- return 'leo'
- elif month == 8:
- if day <= 22:
- return 'leo'
- else:
- return 'virgo'
- elif month == 9:
- if day <= 22:
- return 'virgo'
- else:
- return 'libra'
- elif month == 10:
- if day <= 22:
- return 'libra'
- else:
- return 'scorpio'
- elif month == 11:
- if day <= 21:
- return 'scorpio'
- else:
- return 'sagittarius'
- elif month == 12:
- if day <= 21:
- return 'sagittarius'
- else:
- return 'capricorn'
+ western_sign = WESTERN_SIGNS.get(month)
+ if western_sign[2] >= day:
+ return western_sign[0]
+ else:
+ return western_sign[1]
def interpret_chinese_sign(year):
- if year % 12 == 1:
- return "rooster"
- elif year % 12 == 2:
- return "dog"
- elif year % 12 == 3:
- return "pig"
- elif year % 12 == 4:
- return "rat"
- elif year % 12 == 5:
- return "ox"
- elif year % 12 == 6:
- return "tiger"
- elif year % 12 == 7:
- return "rabbit"
- elif year % 12 == 8:
- return "dragon"
- elif year % 12 == 9:
- return "snake"
- elif year % 12 == 10:
- return "horse"
- elif year % 12 == 11:
- return "sheep"
- elif year % 12 == 0:
- return "monkey"
+ return CHINESE_SIGNS.get(year % 12)
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))