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

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

Към профила на Илиан Стаменов

Резултати

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

Код

def interpret_chinese_sign(year):
signs = [
"monkey",
"rooster",
"dog",
"pig",
"rat",
"ox",
"tiger",
"rabbit",
"dragon",
"snake",
"horse",
"sheep"
]
return signs[year % 12]
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))
def interpret_western_sign(day, month):
months_index = [
["sagittarius", "capricorn", 21],
["capricorn", "aquarius", 20],
["aquarius", "pisces", 18],
["pisces", "aries", 20],
["aries", "taurus", 20],
["taurus", "gemini", 20],
["gemini", "cancer", 20],
["cancer", "leo", 22],
["leo", "virgo", 22],
["virgo", "libra", 22],
["libra", "scorpio", 22],
["scorpio", "sagittarius", 21],
["sagittarius", "capricorn", 21]
]
if months_index[month][2] >= day:
return months_index[month][0]
else:
return months_index[month][1]

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

......
----------------------------------------------------------------------
Ran 6 tests in 0.008s

OK

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

Илиан обнови решението на 11.03.2015 00:02 (преди около 9 години)

+def interpret_chinese_sign(year):
+ signs = {
+ 0: "rooster",
+ 1: "dog",
+ 2: "pig",
+ 3: "rat",
+ 5: "ox",
+ 6: "tiger",
+ 7: "rabbit",
+ 8: "dragon",
+ 9: "snake",
+ 10: "horse",
+ 11: "sheep",
+ 12: "monkey"
+ }
+
+ return signs[year % 12]
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))
+
+
+def interpret_western_sign(day, month):
+ months_index = {
+ 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", "vigro", 22],
+ 9: ["vigro", "libra", 22],
+ 10: ["libra", "scorpio", 22],
+ 11: ["scorpio", "saggitarius", 21],
+ 12: ["saggitarius", "capricorn", 21]
+ }
+
+ if months_index[month][2] >= day:
+ return months_index[month][0]
+ else:
+ return months_index[month][1]

Илиан обнови решението на 11.03.2015 00:49 (преди около 9 години)

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