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 food_timer(food,seconds): return food + int(seconds / 10) def iron_timer(iron,seconds): return iron + int(seconds / 100) def army_timer(food,seconds): return food - int(seconds / 60) def survival(food, iron, seconds): army = True while army: print(food,iron) food = food_timer(food,seconds) iron = iron_timer(iron,seconds) food = army_timer(food,seconds) if food <= 0: print('You are dead') army = False if iron <= 0: print('You lost the war') army = False survival(100,100,100000)

Questions about programming?Chat with your personal AI assistant