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.

def army_supplies(time): iron = 100 food = 100 while time > 0: food -= 1 time -= 60 if time % 100 == 0: iron += 1 if time % 10 == 0: food += 1 if food <= 0: print('You died of hunger') return elif iron <= 0: print('You can not fight') return return food, iron

Questions about programming?Chat with your personal AI assistant