Решение на Да си приготвим нещо за хапване от Димитър Антонов

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

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

Резултати

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

Код

def prepare_meal(number):
n = 1
menu = ""
while number%(3**n) == 0 :
n = n + 1
menu = menu + "spam "
if number%5 == 0 and number%3 == 0:
menu = menu + "and eggs"
else:
if number%5 == 0:
menu = menu + "eggs"
return menu

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

....F.FF..
======================================================================
FAIL: test_one_spam (__main__.FirstHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/test20120506-8116-11yehsp", line 10, in test_one_spam
    self.assertEqual('spam', self.solution.prepare_meal(3))
AssertionError: 'spam' != 'spam '
- spam
+ spam 
?     +


======================================================================
FAIL: test_some_spams (__main__.FirstHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/test20120506-8116-11yehsp", line 13, in test_some_spams
    self.assertEqual('spam spam spam spam', self.solution.prepare_meal(81))
AssertionError: 'spam spam spam spam' != 'spam spam spam spam '
- spam spam spam spam
+ spam spam spam spam 
?                    +


======================================================================
FAIL: test_some_spams_with_additional_multipliers (__main__.FirstHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/test20120506-8116-11yehsp", line 16, in test_some_spams_with_additional_multipliers
    self.assertEqual('spam spam spam spam', self.solution.prepare_meal(81*2*7*11))
AssertionError: 'spam spam spam spam' != 'spam spam spam spam '
- spam spam spam spam
+ spam spam spam spam 
?                    +


----------------------------------------------------------------------
Ran 10 tests in 0.003s

FAILED (failures=3)

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

Димитър обнови решението на 15.03.2012 16:32 (преди над 8 години)

+def prepare_meal(number):
+ n = 1
+ menu = ""
+ while number%(3**n) == 0 :
+ n = n + 1
+ menu = menu + "spam "
+ if number%5 == 0 and number%3 == 0:
+ menu = menu + "and eggs"
+ else:
+ if number%5 == 0:
+ menu = menu + "eggs"
+ return menu