Евгени обнови решението на 10.03.2012 23:21 (преди почти 13 години)
+def prepare_meal(number):
+ meal = add_first(number, 'spam')
+ return meal + add_second(number, 'eggs', meal)
+
+
+def add_first(number, ingredient):
+ if number == 0:
+ return ingredient
+
+ n = 0
+ while number % 3 == 0:
+ n = n + 1
+ number /= 3
+
+ return ('{0} '.format(ingredient) * n).rstrip()
+
+
+def add_second(number, ingredient, meal):
+ if number % 5 == 0:
+ if meal:
+ return ' and ' + ingredient
+ else:
+ return ingredient
+
+ return ''