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

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

Към профила на Георги Мавридис

Резултати

  • 7 точки от тестове
  • 0 бонус точки
  • 7 точки общо
  • 4 успешни тест(а)
  • 2 неуспешни тест(а)

Код

def interpret_western_sign(day, month):
dates_of_signs = [21, 19, 21, 21, 21, 21, 23, 23, 23, 23, 22, 22]
names_of_signs = ['capricorn',
'aquarius',
'pisces',
'aries',
'taurus',
'gemini',
'cancer',
'leo',
'virgo',
'libra',
'scorpio',
'sagittarius']
if day < dates_of_signs[month - 1]:
return names_of_signs[month - 1]
return names_of_signs[month % 12]
def interpret_chinese_sign(year):
modulo = year % 1900 % 12
chinese_sign = ['rat', 'ox', 'tiger', 'rabbit',
'dragon', 'snake', 'horse',
'sheep', 'monkey', 'rooster', 'dog', 'pig']
return chinese_sign[modulo]
def interpret_both_signs(day, month, year):
tup = (interpret_western_sign(day, month), interpret_chinese_sign(year))
return tup

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

...F.F
======================================================================
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-n0xr8h/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-n0xr8h/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.008s

FAILED (failures=2)

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

Георги обнови решението на 08.03.2015 19:14 (преди около 9 години)

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

Георги обнови решението на 10.03.2015 20:55 (преди около 9 години)

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