Веселин обнови решението на 15.03.2012 02:55 (преди почти 13 години)
+import math
+
+
+def prepare_meal(number):
+ n = 0
+ spaces = 0
+ str = ""
+ if number == 0:
+ return str
+ while math.fabs(number) >= 1:
+ if number % 3 == 0:
+ number = number / 3
+ n = n + 1
+ else:
+ break
+ if number % 5 == 0:
+ for x in range(0, n):
+ str = str + "spam "
+ if n is not 0:
+ str = str + "and eggs"
+ else:
+ str = str + "eggs"
+ else:
+ for y in range(0, n):
+ str = str + "spam"
+ spaces = spaces + 1
+ if spaces is not n:
+ str = str + " "
+ return str