Мирослав обнови решението на 15.03.2012 13:34 (преди почти 13 години)
+def prepare_meal(number):
+ result = ''
+ delimiter = [' ', 'and']
+ main_course = ['spam', 'eggs']
+ current_divisor = 1
+ current_power = 0
+ biggest_power = 0
+ while current_divisor < number:
+ current_divisor *= 3
+ current_power += 1
+ if number % current_divisor == 0:
+ biggest_power = current_power
+ for i in range(0, biggest_power):
+ if result != '':
+ result += delimiter[0]
+ result += main_course[0]
+ if number % 5 == 0:
+ if result == '':
+ result += main_course[1]
+ else:
+ result += '%s%s%s%s' % (delimiter[0], delimiter[1],
+ delimiter[0], main_course[1])
+ return result