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

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

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

Резултати

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

Код

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

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

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

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

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

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

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

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