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

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

Към профила на Христиан Димитров

Резултати

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

Код

def interpret_chinese_sign(year):
new_year = year - 1900
chinese_sign_number = new_year % 12
chinese_signs = ["rat", "ox", "tiger", "rabbit", "dragon", "snake",
"horse", "sheep", "monkey", "rooster", "dog", "pig"]
return chinese_signs[chinese_sign_number]
def interpret_western_sign(day, month):
western_signs = {
"aries": [[3, 21], [4, 20]],
"taurus": [[4, 21], [5, 20]],
"gemini": [[5, 21], [6, 20]],
"cancer": [[6, 21], [7, 22]],
"leo": [[7, 23], [8, 22]],
"virgo": [[8, 23], [9, 22]],
"libra": [[9, 23], [10, 22]],
"scorpio": [[10, 23], [11, 21]],
"sagittarius": [[11, 22], [12, 21]],
"capricorn": [[12, 22], [1, 20]],
"aquarius": [[1, 21], [2, 18]],
"pisces": [[2, 19], [3, 20]],
}
for sign, date in western_signs.items():
if month == date[0][0] and day >= date[0][1] or \
month == date[1][0] and day <= date[1][1]:
return sign
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))

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

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

OK

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

Христиан обнови решението на 08.03.2015 12:13 (преди над 9 години)

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

Христиан обнови решението на 08.03.2015 22:19 (преди над 9 години)

def interpret_chinese_sign(year):
new_year = year - 1900
- sign_num = new_year % 12
- if sign_num is 0:
- return "rat"
- elif sign_num is 1:
- return "ox"
- elif sign_num is 2:
- return "tiger"
- elif sign_num is 3:
- return "rabbit"
- elif sign_num is 4:
- return "dragon"
- elif sign_num is 5:
- return "snake"
- elif sign_num is 6:
- return "horse"
- elif sign_num is 7:
- return "sheep"
- elif sign_num is 8:
- return "monkey"
- elif sign_num is 9:
- return "rooster"
- elif sign_num is 10:
- return "dog"
- elif sign_num is 11:
- return "pig"
+ chinese_sign_num = new_year % 12
+ chinese_sign_dict = {
+ 0: "rat",
+ 1: "ox",
+ 2: "tiger",
+ 3: "rabbit",
+ 4: "dragon",
+ 5: "snake",
+ 6: "horse",
+ 7: "sheep",
+ 8: "monkey",
+ 9: "rooster",
+ 10: "dog",
+ 11: "pig",
+ }
+ for sign_num in chinese_sign_dict:
+ if chinese_sign_num == sign_num:
+ return chinese_sign_dict[sign_num]
def interpret_western_sign(day, month):
- if month is 3 and day >= 21 or \
- month is 4 and day <= 20:
- return "aries"
- elif month is 4 and day >= 21 or \
- month is 5 and day <= 20:
- return "taurus"
- elif month is 5 and day >= 21 or \
- month is 6 and day <= 20:
- return "gemini"
- elif month is 6 and day >= 21 or \
- month is 7 and day <= 22:
- return "cancer"
- elif month is 7 and day >= 23 or \
- month is 8 and day <= 22:
- return "leo"
- elif month is 8 and day >= 23 or \
- month is 9 and day <= 22:
- return "virgo"
- elif month is 9 and day >= 23 or \
- month is 10 and day <= 22:
- return "libra"
- elif month is 10 and day >= 23 or \
- month is 11 and day <= 21:
- return "scorpio"
- elif month is 11 and day >= 22 or \
- month is 12 and day <= 21:
- return "sagittarius"
- elif month is 12 and day >= 22 or \
- month is 1 and day <= 20:
- return "capricorn"
- elif month is 1 and day >= 21 or \
- month is 2 and day <= 18:
- return "aquarius"
- elif month is 2 and day >= 19 or \
- month is 3 and day <= 20:
- return "pisces"
+ western_sign_dict = {
+ "aries": [[3, 21], [4, 20]],
+ "taurus": [[4, 21], [5, 20]],
+ "gemini": [[5, 21], [6, 20]],
+ "cancer": [[6, 21], [7, 22]],
+ "leo": [[7, 23], [8, 22]],
+ "virgo": [[8, 23], [9, 22]],
+ "libra": [[9, 23], [10, 22]],
+ "scorpio": [[10, 23], [11, 21]],
+ "sagittarius": [[11, 22], [12, 21]],
+ "capricorn": [[12, 22], [1, 20]],
+ "aquarius": [[1, 21], [2, 18]],
+ "pisces": [[2, 19], [3, 20]],
+ }
+ for sign, date in western_sign_dict.items():
+ if month == date[0][0] and day >= date[0][1] or \
+ month == date[1][0] and day <= date[1][1]:
+ return sign
def interpret_both_signs(day, month, year):
western_sign = interpret_western_sign(day, month)
chinese_sign = interpret_chinese_sign(year)
- return (western_sign, chinese_sign)
+ return (western_sign, chinese_sign)

Христиан обнови решението на 09.03.2015 23:30 (преди над 9 години)

def interpret_chinese_sign(year):
new_year = year - 1900
- chinese_sign_num = new_year % 12
- chinese_sign_dict = {
- 0: "rat",
- 1: "ox",
- 2: "tiger",
- 3: "rabbit",
- 4: "dragon",
- 5: "snake",
- 6: "horse",
- 7: "sheep",
- 8: "monkey",
- 9: "rooster",
- 10: "dog",
- 11: "pig",
- }
- for sign_num in chinese_sign_dict:
- if chinese_sign_num == sign_num:
- return chinese_sign_dict[sign_num]
+ chinese_sign_number = new_year % 12
+ chinese_signs = ["rat", "ox", "tiger", "rabbit", "dragon", "snake",
+ "horse", "sheep", "monkey", "rooster", "dog", "pig"]
+ return chinese_signs[chinese_sign_number]
def interpret_western_sign(day, month):
western_sign_dict = {
"aries": [[3, 21], [4, 20]],
"taurus": [[4, 21], [5, 20]],
"gemini": [[5, 21], [6, 20]],
"cancer": [[6, 21], [7, 22]],
"leo": [[7, 23], [8, 22]],
"virgo": [[8, 23], [9, 22]],
"libra": [[9, 23], [10, 22]],
"scorpio": [[10, 23], [11, 21]],
"sagittarius": [[11, 22], [12, 21]],
"capricorn": [[12, 22], [1, 20]],
"aquarius": [[1, 21], [2, 18]],
"pisces": [[2, 19], [3, 20]],
}
for sign, date in western_sign_dict.items():
if month == date[0][0] and day >= date[0][1] or \
month == date[1][0] and day <= date[1][1]:
return sign
def interpret_both_signs(day, month, year):
- western_sign = interpret_western_sign(day, month)
- chinese_sign = interpret_chinese_sign(year)
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))
- return (western_sign, chinese_sign)

Христиан обнови решението на 10.03.2015 00:15 (преди над 9 години)

def interpret_chinese_sign(year):
new_year = year - 1900
chinese_sign_number = new_year % 12
chinese_signs = ["rat", "ox", "tiger", "rabbit", "dragon", "snake",
"horse", "sheep", "monkey", "rooster", "dog", "pig"]
return chinese_signs[chinese_sign_number]
def interpret_western_sign(day, month):
- western_sign_dict = {
+ western_signs = {
"aries": [[3, 21], [4, 20]],
"taurus": [[4, 21], [5, 20]],
"gemini": [[5, 21], [6, 20]],
"cancer": [[6, 21], [7, 22]],
"leo": [[7, 23], [8, 22]],
"virgo": [[8, 23], [9, 22]],
"libra": [[9, 23], [10, 22]],
"scorpio": [[10, 23], [11, 21]],
"sagittarius": [[11, 22], [12, 21]],
"capricorn": [[12, 22], [1, 20]],
"aquarius": [[1, 21], [2, 18]],
"pisces": [[2, 19], [3, 20]],
}
- for sign, date in western_sign_dict.items():
+ for sign, date in western_signs.items():
if month == date[0][0] and day >= date[0][1] or \
month == date[1][0] and day <= date[1][1]:
return sign
def interpret_both_signs(day, month, year):
- return (interpret_western_sign(day, month), interpret_chinese_sign(year))
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))
+# print(interpret_both_signs(1, 5, 1993))

Христиан обнови решението на 11.03.2015 09:49 (преди над 9 години)

def interpret_chinese_sign(year):
new_year = year - 1900
chinese_sign_number = new_year % 12
chinese_signs = ["rat", "ox", "tiger", "rabbit", "dragon", "snake",
"horse", "sheep", "monkey", "rooster", "dog", "pig"]
return chinese_signs[chinese_sign_number]
def interpret_western_sign(day, month):
western_signs = {
"aries": [[3, 21], [4, 20]],
"taurus": [[4, 21], [5, 20]],
"gemini": [[5, 21], [6, 20]],
"cancer": [[6, 21], [7, 22]],
"leo": [[7, 23], [8, 22]],
"virgo": [[8, 23], [9, 22]],
"libra": [[9, 23], [10, 22]],
"scorpio": [[10, 23], [11, 21]],
"sagittarius": [[11, 22], [12, 21]],
"capricorn": [[12, 22], [1, 20]],
"aquarius": [[1, 21], [2, 18]],
"pisces": [[2, 19], [3, 20]],
}
for sign, date in western_signs.items():
if month == date[0][0] and day >= date[0][1] or \
month == date[1][0] and day <= date[1][1]:
return sign
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_sign(year))
-# print(interpret_both_signs(1, 5, 1993))