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

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

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

Резултати

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

Код

western_signs = ([
"capricorn", "aquarius", "pisces",
"aries", "taurus", "gemini",
"cancer", "leo", "virgo",
"libra", "scorpio", "sagittarius"
])
month_to_zodiacs = {
1: (western_signs[0], 20, western_signs[1]),
2: (western_signs[1], 18, western_signs[2]),
3: (western_signs[2], 20, western_signs[3]),
4: (western_signs[3], 20, western_signs[4]),
5: (western_signs[4], 20, western_signs[5]),
6: (western_signs[5], 20, western_signs[6]),
7: (western_signs[6], 22, western_signs[7]),
8: (western_signs[7], 22, western_signs[8]),
9: (western_signs[8], 22, western_signs[9]),
10: (western_signs[9], 22, western_signs[10]),
11: (western_signs[10], 21, western_signs[11]),
12: (western_signs[11], 21, western_signs[0])
}
def interpret_western_sign(day, month):
if day <= month_to_zodiacs[month][1]:
return month_to_zodiacs[month][0]
else:
return month_to_zodiacs[month][2]
chinise_sign = {
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_chinese_sign(year):
return chinise_sign[year % 12]
def interpret_both_signs(day, month, year):
western_signz = interpret_western_sign(day, month)
chinise_signz = interpret_chinese_sign(year)
return (western_signz, chinise_signz)

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

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

OK

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

Павел обнови решението на 09.03.2015 10:09 (преди над 9 години)

+def interpret_western_sign(day, month):
+ if (month == 1 and day >= 21) or (month == 2 and day <= 18):
+ return "aquarius"
+ elif (month == 2 and day >= 19) or (month == 3 and day <= 20):
+ return "pisces"
+ elif (month == 3 and day >= 21) or (month == 4 and day <= 20):
+ return "aries"
+ elif (month == 4 and day >= 21) or (month == 5 and day <= 20):
+ return "taurus"
+ elif (month == 5 and day >= 21) or (month == 6 and day <= 20):
+ return "gemini"
+ elif (month == 6 and day >= 21) or (month == 7 and day <= 22):
+ return "cancer"
+ elif (month == 7 and day >= 23) or (month == 8 and day <= 22):
+ return "leo"
+ elif (month == 8 and day >= 23) or (month == 9 and day <= 22):
+ return "virgo"
+ elif (month == 9 and day >= 23) or (month == 10 and day <= 22):
+ return "libra"
+ elif (month == 10 and day >= 23) or (month == 11 and day <= 21):
+ return "scorpio"
+ elif (month == 11 and day >= 22) or (month == 12 and day <= 21):
+ return "sagittarius"
+ elif (month == 12 and day >= 22) or (month == 1 and day <= 20):
+ return "capricorn"
+ else:
+ return "Invalid input"
+
+
+def interpret_chinese_sign(year):
+ if 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"
+ elif year % 12 == 1:
+ return "rooster"
+ elif year % 12 == 2:
+ return "dog"
+ elif year % 12 == 3:
+ return "pig"
+ else:
+ return "Invalid input"
+
+
+def interpret_both_signs(day, month, year):
+ western_sing = interpret_western_sign(day, month)
+ chinese_sing = interpret_chinese_sign(year)
+ return (western_sing, chinese_sing)

Павел обнови решението на 09.03.2015 22:52 (преди над 9 години)

def interpret_western_sign(day, month):
if (month == 1 and day >= 21) or (month == 2 and day <= 18):
return "aquarius"
elif (month == 2 and day >= 19) or (month == 3 and day <= 20):
return "pisces"
elif (month == 3 and day >= 21) or (month == 4 and day <= 20):
return "aries"
elif (month == 4 and day >= 21) or (month == 5 and day <= 20):
return "taurus"
elif (month == 5 and day >= 21) or (month == 6 and day <= 20):
return "gemini"
elif (month == 6 and day >= 21) or (month == 7 and day <= 22):
return "cancer"
elif (month == 7 and day >= 23) or (month == 8 and day <= 22):
return "leo"
elif (month == 8 and day >= 23) or (month == 9 and day <= 22):
return "virgo"
elif (month == 9 and day >= 23) or (month == 10 and day <= 22):
return "libra"
elif (month == 10 and day >= 23) or (month == 11 and day <= 21):
return "scorpio"
elif (month == 11 and day >= 22) or (month == 12 and day <= 21):
return "sagittarius"
elif (month == 12 and day >= 22) or (month == 1 and day <= 20):
return "capricorn"
else:
return "Invalid input"
+chinise_sign = {
+ 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_chinese_sign(year):
- if 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"
- elif year % 12 == 1:
- return "rooster"
- elif year % 12 == 2:
- return "dog"
- elif year % 12 == 3:
- return "pig"
- else:
- return "Invalid input"
+ return chinise_sign[year % 12]
def interpret_both_signs(day, month, year):
- western_sing = interpret_western_sign(day, month)
- chinese_sing = interpret_chinese_sign(year)
+ western_sign = interpret_western_sign(day, month)
- return (western_sing, chinese_sing)
+ chinise_sign = interpret_chinese_sign(year)
+ return (western_sign, chinise_sign)

Павел обнови решението на 10.03.2015 08:22 (преди над 9 години)

+western_signs = ([
+ "capricorn", "aquarius", "pisces",
+ "aries", "taurus", "gemini",
+ "cancer", "leo", "virgo",
+ "libra", "scorpio", "sagittarius"
+ ])
+
+month_to_zodiacs = {
+ 1: (western_signs[0], 20, western_signs[1]),
+ 2: (western_signs[1], 18, western_signs[2]),
+ 3: (western_signs[2], 20, western_signs[3]),
+ 4: (western_signs[3], 20, western_signs[4]),
+ 5: (western_signs[4], 20, western_signs[5]),
+ 6: (western_signs[5], 20, western_signs[6]),
+ 7: (western_signs[6], 22, western_signs[7]),
+ 8: (western_signs[7], 22, western_signs[8]),
+ 9: (western_signs[8], 22, western_signs[9]),
+ 10: (western_signs[9], 22, western_signs[10]),
+ 11: (western_signs[10], 21, western_signs[11]),
+ 12: (western_signs[11], 21, western_signs[0])
+}
+
+
def interpret_western_sign(day, month):
- if (month == 1 and day >= 21) or (month == 2 and day <= 18):
- return "aquarius"
- elif (month == 2 and day >= 19) or (month == 3 and day <= 20):
- return "pisces"
- elif (month == 3 and day >= 21) or (month == 4 and day <= 20):
- return "aries"
- elif (month == 4 and day >= 21) or (month == 5 and day <= 20):
- return "taurus"
- elif (month == 5 and day >= 21) or (month == 6 and day <= 20):
- return "gemini"
- elif (month == 6 and day >= 21) or (month == 7 and day <= 22):
- return "cancer"
- elif (month == 7 and day >= 23) or (month == 8 and day <= 22):
- return "leo"
- elif (month == 8 and day >= 23) or (month == 9 and day <= 22):
- return "virgo"
- elif (month == 9 and day >= 23) or (month == 10 and day <= 22):
- return "libra"
- elif (month == 10 and day >= 23) or (month == 11 and day <= 21):
- return "scorpio"
- elif (month == 11 and day >= 22) or (month == 12 and day <= 21):
- return "sagittarius"
- elif (month == 12 and day >= 22) or (month == 1 and day <= 20):
- return "capricorn"
+ if day <= month_to_zodiacs[month][1]:
+ return month_to_zodiacs[month][0]
else:
- return "Invalid input"
+ return month_to_zodiacs[month][2]
chinise_sign = {
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_chinese_sign(year):
return chinise_sign[year % 12]
def interpret_both_signs(day, month, year):
- western_sign = interpret_western_sign(day, month)
- chinise_sign = interpret_chinese_sign(year)
+ western_signz = interpret_western_sign(day, month)
- return (western_sign, chinise_sign)
+ chinise_signz = interpret_chinese_sign(year)
+ return (western_signz, chinise_signz)