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

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

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

Резултати

  • 5 точки от тестове
  • 1 отнета точка
  • 4 точки общо
  • 3 успешни тест(а)
  • 3 неуспешни тест(а)

Код

def interpret_chinese_signs(year):
chinese_signs = ['monkey', 'rooster', 'dog', 'pig', 'rat', 'ox', 'tiger',
'rabbit', 'dragon', 'snake', 'horse', 'sheep']
return chinese_signs[year % 12]
def interpret_western_sign(day, month):
if (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 <= 21):
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'
elif (month == 1 and day >= 21) or (month == 2 and day <= 19):
return 'aquarius'
def interpret_both_signs(day, month, year):
return (interpret_western_sign(day, month), interpret_chinese_signs(year))

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

E..E.E
======================================================================
ERROR: test_chinese_signs (test.TestSigns)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20150312-24164-1u8gltv/test.py", line 6, in test_chinese_signs
    self.assertEqual(solution.interpret_chinese_sign(1986), 'tiger')
AttributeError: 'module' object has no attribute 'interpret_chinese_sign'

======================================================================
ERROR: test_negative_years (test.TestSigns)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20150312-24164-1u8gltv/test.py", line 26, in test_negative_years
    self.assertEqual(solution.interpret_chinese_sign(-23), 'rooster')
AttributeError: 'module' object has no attribute 'interpret_chinese_sign'

======================================================================
ERROR: test_zeroth_year (test.TestSigns)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20150312-24164-1u8gltv/test.py", line 29, in test_zeroth_year
    self.assertEqual(solution.interpret_chinese_sign(0), 'monkey')
AttributeError: 'module' object has no attribute 'interpret_chinese_sign'

----------------------------------------------------------------------
Ran 6 tests in 0.007s

FAILED (errors=3)

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

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

+def interpret_chinese_signs(year):
+ chinese_signs = ['monkey', 'rooster', 'dog', 'pig', 'rat', 'ox', 'tiger',
+ 'rabbit', 'dragon', 'snake', 'horse', 'sheep']
+ return chinese_signs[year % 12]
+
+
+def interpret_western_sign(day, month):
+ if (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 <= 21):
+ 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'
+ elif (month == 1 and day >= 21) or (month == 2 and day <= 19):
+ return 'aquarius'
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month), interpret_chinese_signs(year))