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, iron, food_production, iron_production): while True: if food < 0: return "You died." else: food_production = food_production + 10 iron_production = iron_production + 100 food = food - 1 if food_production == 10: food = food + 1 food_production = 0 if iron_production == 100: iron = iron + 1 iron_production = 0 return "food = %s , iron = %s" % (food, iron) food = 100 iron = 100 food_production = 0 iron_production = 0 army(food, iron, food_production, iron_production)

Questions about programming?Chat with your personal AI assistant