Георги обнови решението на 09.03.2012 01:51 (преди почти 13 години)
+def get_spam_count(number):
+ if number % 3 != 0:
+ return 0
+ else:
+ return 1 + get_spam_count(number//3)
+
+def prepare_meal(number):
+ add_some_eggs = not number % 5
+ spam_count = get_spam_count(number)
+
+ meal = 'spam ' * spam_count
+ if add_some_eggs :
+ if spam_count :
+ meal += 'and '
+ meal += 'eggs'
+ else :
+ meal = meal.strip()
+
+ return meal