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

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

Към профила на Антонио Илиев

Резултати

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

Код

def interpret_western_sign (day, month) :
signs = [(21, "capricorn"), (20, "aquarius"), (21, "pisces"),
(21, "aries"), (21, "taurus"), (21, "gemini"),
(23, "cancer"), (23, "leo"), (23, "virgo"),
(23, "libra"), (22, "scorpio"), (22, "sagittarius")]
if month > 0 and month <= 12 and day > 0 :
if month < 8 and month % 2 is not 0 and day > 31 :
return
if month >= 8 and month % 2 is 0 and day > 31 :
return
if month < 8 and month % 2 is 0 and day > 30 and month is not 2 :
return
if month > 8 and month % 2 is not 0 and day > 30 :
return
if month is 2 :
return
else :
if day < signs[month-1] [0] :
return signs[month-1] [1]
else :
return signs[month] [1]
else:
return
def interpret_chinese_sign (year) :
chinese_signs = ["rat", "ox", "tiger", "rabbit",
"dragon", "snake", "horse", "sheep",
"monkey", "rooster", "dog", "pig"]
index = year % 1000 % 12
return chinese_signs [index]
def interpret_both_signs (day, month, year) :
western_sign = interpret_western_sign(day, month)
chinese_sign = interpret_chinese_sign(year)
both_signs = (western_sign, chinese_sign)
return both_signs

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

..FF.F
======================================================================
FAIL: test_leap_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-1fjx7jq/test.py", line 32, in test_leap_year
    self.assertEqual(solution.interpret_western_sign(29, 2), 'pisces')
AssertionError: None != 'pisces'

======================================================================
FAIL: 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-1fjx7jq/test.py", line 26, in test_negative_years
    self.assertEqual(solution.interpret_chinese_sign(-23), 'rooster')
AssertionError: 'snake' != 'rooster'
- snake
+ rooster


======================================================================
FAIL: 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-1fjx7jq/test.py", line 29, in test_zeroth_year
    self.assertEqual(solution.interpret_chinese_sign(0), 'monkey')
AssertionError: 'rat' != 'monkey'
- rat
+ monkey


----------------------------------------------------------------------
Ran 6 tests in 0.011s

FAILED (failures=3)

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

Антонио обнови решението на 11.03.2015 09:34 (преди над 9 години)

+def interpret_western_sign (day, month) :
+ signs = [(21, "capricorn"), (20, "aquarius"), (21, "pisces")
+ (21, "aries"), (21, "taurus"), (21, "gemini")
+ (23, "cancer"), (23, "leo"), (23, "virgo")
+ (23, "libra"), (22, "scorpio"), (22, "sagittarius")]
+ if month > 0 and month <= 12 and day > 0 :
+ if month < 8 and month % 2 is not 0 and day > 31 :
+ return
+ if month >= 8 and month % 2 is 0 and day > 31 :
+ return
+ if month < 8 and month % 2 is 0 and day > 30 and month is not 2 :
+ return
+ if month > 8 and month % 2 is not 0 and day > 30 :
+ return
+ if month is 2 :
+ return
+ else :
+ if day < signs[month-1] [0] :
+ return signs[month-1] [1]
+ else :
+ return signs[month] [1]
+ else:
+ return
+def interpret_chinese_sign (year) :
+ chinese_signs = ["rat", "ox", "tiger", "rabbit"
+ "dragon", "snake", "horse", "sheep"
+ "monkey", "rooster", "dog", "pig"]
+ index = year % 1900 % 12
+ return chinese_signs [index]
+
+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)

Антонио обнови решението на 11.03.2015 14:08 (преди над 9 години)

def interpret_western_sign (day, month) :
- signs = [(21, "capricorn"), (20, "aquarius"), (21, "pisces")
- (21, "aries"), (21, "taurus"), (21, "gemini")
- (23, "cancer"), (23, "leo"), (23, "virgo")
+ signs = [(21, "capricorn"), (20, "aquarius"), (21, "pisces"),
+ (21, "aries"), (21, "taurus"), (21, "gemini"),
+ (23, "cancer"), (23, "leo"), (23, "virgo"),
(23, "libra"), (22, "scorpio"), (22, "sagittarius")]
if month > 0 and month <= 12 and day > 0 :
if month < 8 and month % 2 is not 0 and day > 31 :
return
if month >= 8 and month % 2 is 0 and day > 31 :
return
if month < 8 and month % 2 is 0 and day > 30 and month is not 2 :
return
if month > 8 and month % 2 is not 0 and day > 30 :
return
if month is 2 :
return
else :
if day < signs[month-1] [0] :
return signs[month-1] [1]
else :
return signs[month] [1]
else:
return
def interpret_chinese_sign (year) :
- chinese_signs = ["rat", "ox", "tiger", "rabbit"
- "dragon", "snake", "horse", "sheep"
+ chinese_signs = ["rat", "ox", "tiger", "rabbit",
+ "dragon", "snake", "horse", "sheep",
"monkey", "rooster", "dog", "pig"]
- index = year % 1900 % 12
+ index = year % 1000 % 12
return chinese_signs [index]
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)
+ both_signs = (western_sign, chinese_sign)
+ return both_signs