Allen Chen

Generation

generate functionSun, 02 Apr 2023

you are helping an army. if you don't send supplies, you would die. if the food drops to 0 all would die. if you run out of iron, the army could not fight. you will start with 100 food and 100 iron. it takes 10 seconds to produce 1 food and 100 seconds to produce 1 iron.The army eats 1 food every 60 sec.you decide how many food we produce.

def army(food_p, iron_p): t = 0 while t < 60: if food > 0 and iron > 0: food = food + food_p iron = iron + iron_p food = food - 1 iron = iron - 1 else: print(t, "seconds,all dead") break t = t + 1 print(t, food, iron, "seconds")

Questions about programming?Chat with your personal AI assistant