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.

food = 100 iron = 100 time = 0 def send_supplies(): global food global iron global time food = food - 1 iron = iron - 1 time = time + 10 def produce_food(): global food global time food = food + 1 time = time + 100 def produce_iron(): global iron global time iron = iron + 1 time = time + 100 def check_for_death(): global food global iron if food <= 0 and iron <= 0: print("You are dead") print("The army is dead") exit() elif food <= 0: print("You are dead") print("The army is still alive") exit() elif iron <= 0: print("You are still alive") print("The army is dead") exit() send_supplies() produce_food() produce_iron()

Questions about programming?Chat with your personal AI assistant