Условие следующее:
At the warm-up event for Oscar’s All Star Hot Dog Eating Contest, Al ate one
hot dog. Bob then showed him up by eating three hot dogs. Not to be outdone
Carl ate five. This continued with each contestant eating two more hot dogs
than the previous contestant. How many hot dogs did Zeno (the 26th and final
contestant) eat?
Если честно у меня не совсем получается отследить логику, как можно написать такой код на Python. У меня пока что получается следующее и естественно код не работает:
def hot_dog(guest_number):
hot_dogs_number = [1,]
for person in range(1,guest_number):
if person == 1:
print(1)
elif person > 1:
hot_dog = hot_dogs_number[:1] + 2
hot_dogs_number.append(hot_dog)
print(hot_dogs_number[-1])
At the warm-up event for Oscar’s All Star Hot Dog Eating Contest, Al ate one
hot dog. Bob then showed him up by eating three hot dogs. Not to be outdone
Carl ate five. This continued with each contestant eating two more hot dogs
than the previous contestant. How many hot dogs did Zeno (the 26th and final
contestant) eat?
Если честно у меня не совсем получается отследить логику, как можно написать такой код на Python. У меня пока что получается следующее и естественно код не работает:
def hot_dog(guest_number):
hot_dogs_number = [1,]
for person in range(1,guest_number):
if person == 1:
print(1)
elif person > 1:
hot_dog = hot_dogs_number[:1] + 2
hot_dogs_number.append(hot_dog)
print(hot_dogs_number[-1])