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

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

Към профила на Кристиан Ташков

Резултати

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

Код

WESTERN_SIGNS = ['aries', 'taurus', 'gemini', 'cancer',
'leo', 'virgo', 'libra', 'scorpio',
'sagittarius', 'capricorn', 'aquarius', 'pisces']
CHINESE_SIGNS = ['monkey', 'rooster', 'dog', 'pig',
'rat', 'ox', 'tiger', 'rabbit',
'dragon', 'snake', 'horse', 'sheep']
WESTERN_SIGNS_BOUNDRIES = [21, 21, 21, 21,
23, 23, 23, 23,
22, 22, 21, 19]
FIRST_MONTH = 3
def interpret_western_sign(day, month):
month_index = month - FIRST_MONTH
if day >= WESTERN_SIGNS_BOUNDRIES[month_index]:
return WESTERN_SIGNS[month_index]
else:
return WESTERN_SIGNS[month_index - 1]
def interpret_chinese_sign(year):
return CHINESE_SIGNS[year % len(CHINESE_SIGNS)]
def interpret_both_signs(day, month, year):
return interpret_western_sign(day, month), interpret_chinese_sign(year)

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

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

OK

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

Кристиан обнови решението на 09.03.2015 20:17 (преди над 9 години)

+western_signs = ['aries', 'taurus', 'gemini', 'cancer',
+ 'leo', 'virgo', 'libra', 'scorpio',
+ 'sagittarius', 'capricorn', 'aquarius', 'pisces']
+
+chinese_signs = ['monkey', 'rooster', 'dog', 'pig',
+ 'rat', 'ox', 'tiger', 'rabbit',
+ 'dragon', 'snake', 'horse', 'sheep']
+
+first_month = 3
+total_months = 12
+
+western_signs_boundries = [21, 21, 21, 21,
+ 23, 23, 23, 23,
+ 22, 22, 21, 19]
+
+def interpret_western_sign(day, month):
+ month_index = (month - first_month) % total_months
+ if day >= western_signs_boundries[month_index]:
+ return western_signs[month_index]
+ else:
+ return western_signs[(month_index - 1) % total_months]
+
+def interpret_chinese_sign(year):
+ return chinese_signs[year % total_months]
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_sign(year))

Кристиан обнови решението на 10.03.2015 11:45 (преди над 9 години)

-western_signs = ['aries', 'taurus', 'gemini', 'cancer',
+WESTERN_SIGNS = ['aries', 'taurus', 'gemini', 'cancer',
'leo', 'virgo', 'libra', 'scorpio',
'sagittarius', 'capricorn', 'aquarius', 'pisces']
-chinese_signs = ['monkey', 'rooster', 'dog', 'pig',
+CHINESE_SIGNS = ['monkey', 'rooster', 'dog', 'pig',
'rat', 'ox', 'tiger', 'rabbit',
'dragon', 'snake', 'horse', 'sheep']
-first_month = 3
-total_months = 12
-
-western_signs_boundries = [21, 21, 21, 21,
+WESTERN_SIGNS_BOUNDRIES = [21, 21, 21, 21,
23, 23, 23, 23,
22, 22, 21, 19]
+FIRST_MONTH = 3
+
+
def interpret_western_sign(day, month):
- month_index = (month - first_month) % total_months
- if day >= western_signs_boundries[month_index]:
- return western_signs[month_index]
+ month_index = (month - FIRST_MONTH) % len(WESTERN_SIGNS)
+ if day >= WESTERN_SIGNS_BOUNDRIES[month_index]:
+ return WESTERN_SIGNS[month_index]
else:
- return western_signs[(month_index - 1) % total_months]
+ return WESTERN_SIGNS[(month_index - 1) % len(WESTERN_SIGNS)]
+
def interpret_chinese_sign(year):
- return chinese_signs[year % total_months]
-
+ return CHINESE_SIGNS[year % len(CHINESE_SIGNS)]
+
+
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)

Кристиан обнови решението на 10.03.2015 14:25 (преди над 9 години)

-WESTERN_SIGNS = ['aries', 'taurus', 'gemini', 'cancer',
- 'leo', 'virgo', 'libra', 'scorpio',
+WESTERN_SIGNS = ['aries', 'taurus', 'gemini', 'cancer',
+ 'leo', 'virgo', 'libra', 'scorpio',
'sagittarius', 'capricorn', 'aquarius', 'pisces']
CHINESE_SIGNS = ['monkey', 'rooster', 'dog', 'pig',
'rat', 'ox', 'tiger', 'rabbit',
'dragon', 'snake', 'horse', 'sheep']
WESTERN_SIGNS_BOUNDRIES = [21, 21, 21, 21,
23, 23, 23, 23,
22, 22, 21, 19]
FIRST_MONTH = 3
def interpret_western_sign(day, month):
month_index = (month - FIRST_MONTH) % len(WESTERN_SIGNS)
if day >= WESTERN_SIGNS_BOUNDRIES[month_index]:
return WESTERN_SIGNS[month_index]
else:
return WESTERN_SIGNS[(month_index - 1) % len(WESTERN_SIGNS)]
def interpret_chinese_sign(year):
return CHINESE_SIGNS[year % len(CHINESE_SIGNS)]
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)

Кристиан обнови решението на 10.03.2015 19:18 (преди над 9 години)

WESTERN_SIGNS = ['aries', 'taurus', 'gemini', 'cancer',
'leo', 'virgo', 'libra', 'scorpio',
'sagittarius', 'capricorn', 'aquarius', 'pisces']
CHINESE_SIGNS = ['monkey', 'rooster', 'dog', 'pig',
'rat', 'ox', 'tiger', 'rabbit',
'dragon', 'snake', 'horse', 'sheep']
WESTERN_SIGNS_BOUNDRIES = [21, 21, 21, 21,
23, 23, 23, 23,
22, 22, 21, 19]
FIRST_MONTH = 3
def interpret_western_sign(day, month):
- month_index = (month - FIRST_MONTH) % len(WESTERN_SIGNS)
+ month_index = month - FIRST_MONTH
if day >= WESTERN_SIGNS_BOUNDRIES[month_index]:
return WESTERN_SIGNS[month_index]
else:
- return WESTERN_SIGNS[(month_index - 1) % len(WESTERN_SIGNS)]
+ return WESTERN_SIGNS[month_index - 1]
def interpret_chinese_sign(year):
return CHINESE_SIGNS[year % len(CHINESE_SIGNS)]
def interpret_both_signs(day, month, year):
return interpret_western_sign(day, month), interpret_chinese_sign(year)