Задача Bread Factory - молба за съдействие
Здравейте, ето това е решението, до което аз успявам да стигна, но не взимам макс точки от Judge.:
input_info = input().split("|") energy = 100 coins = 100 for el in input_info: elements = el.split("-") name = elements[0] value = int(elements[1]) if name == "rest": gained_energy = value if energy + gained_energy > 100: gained_energy = 0 print(f"You gained {gained_energy} energy.") print(f"Current energy: {energy}.") else: energy += gained_energy print(f"You gained {gained_energy} energy.") print(f"Current energy: {energy}.") elif name == "order": earned_coins = value energy -= 30 if energy < 0: energy += 80 print("You had to rest!") else: coins += earned_coins print(f"You earned {earned_coins} coins.") else: if coins >= value: coins -= value print(f"You bought {name}.") else: print(f"Closed! Cannot afford {name}.") exit() print("Day completed!") print(f"Coins: {coins}") print(f"Energy: {energy}")
Моля да посочите къде бъркам,
Благодаря