Тодор обнови решението на 15.03.2012 13:36 (преди почти 13 години)
+def get_times_divided(number, divisor):
+ if number % divisor != 0:
+ return 0
+ else:
+ return 1 + get_times_divided(number/divisor, divisor)
+
+
+def prepare_meal(number):
+ spam_count = get_times_divided(number, 3)
+ has_eggs = (number % 5 == 0)
+ meal = []
+
+ if spam_count != 0:
+ for every_spam in range(spam_count):
+ meal.append('spam')
+ if has_eggs:
+ meal.append('and eggs')
+ elif has_eggs:
+ meal.append('eggs')
+
+ return ' '.join(meal)