# Решение на Да си приготвим нещо за хапване от Томислав Иванов

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

Към профила на Томислав Иванов

## Резултати

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

## Код

def prepare_meal(number):
meal = []
degree = 1
include_eggs = False
while (3 ** degree) < number + 1:
if (number % (3 ** degree)) == 0:
if (include_eggs == True):
meal.insert(0, 'spam')
else:
meal.append('spam')
if (number % (5 ** degree)) == 0 and meal.count('spam') > 0 and meal.count('and eggs') == 0:
meal.append('and eggs')
include_eggs = True
else:
if((number % (5 ** degree)) == 0):
meal.append('eggs')
include_eggs = True
degree = 1 + degree
return ' '.join(str(n) for n in meal)
print(prepare_meal(45))

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

.F........
======================================================================
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test20120506-8116-19cma7p", line 22, in test_eggs_with_additional_egg_multipliers
self.assertEqual('eggs', self.solution.prepare_meal(5**4))
AssertionError: 'eggs' != 'eggs eggs eggs eggs'
- eggs
+ eggs eggs eggs eggs

----------------------------------------------------------------------
Ran 10 tests in 0.002s

FAILED (failures=1)

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

### Томислав обнови решението на 15.03.2012 17:46 (преди над 8 години)

+def prepare_meal(number):
+ meal = []
+ degree = 1
+ include_eggs = False
+ while (3 ** degree) < number + 1:
+ if (number % (3 ** degree)) == 0:
+ if (include_eggs == True):
+ meal.insert(0, 'spam')
+ else:
+ meal.append('spam')
+ if (number % (5 ** degree)) == 0 and meal.count('spam') > 0 and meal.count('and eggs') == 0:
+ meal.append('and eggs')
+ include_eggs = True
+ else:
+ if((number % (5 ** degree)) == 0):
+ meal.append('eggs')
+ include_eggs = True
+ degree = 1 + degree
+ return ' '.join(str(n) for n in meal)
+
+print(prepare_meal(45))