Jan 2nd, 2021
42
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. events = input().split("|")
2. ENERGY = 100
3. gain_energy = 0
4. total_energy = ENERGY - gain_energy
5. profit = 0
6. total_profit = profit + 100
7. counter = 0
8. for even in events:
9.
10.     ingredient = even.split("-")
11.     even = ingredient[0]
12.     number = ingredient[1]
13.
14.     if even == "order":
15.         if total_energy < 30:
17.             gain_energy += 50
18.             continue
19.         profit += int(number)
20.         if total_profit > 100:
21.             total_energy = 100
22.         total_energy -= 30
23.         counter += 1
24.         print(f"You earned {number} coins.")
25.         # if counter > 3:
26.         #     print(f"You had to rest!")
27.         #     gain_energy += 50
28.         #     continue
29.         # print(f"You earned {number} coins.")
30.     elif even == "rest":
31.         total_energy += int(number)
32.         if total_energy > 100:
33.             print(f"You gained 0 energy.")
34.             print(f"Current energy: {ENERGY}.")
35.             total_energy = ENERGY
36.             # continue
37.         else:
38.             gain_energy += int(number)
39.             print(f"You gained {number} energy.")
40.
41.     else:
42.         if total_profit >= int(number):
43.             total_profit -= int(number)
44.             print(f"You bought {even}.")
45.         else:
46.             print(f"Closed! Cannot afford {even}.")
47.             break
48.
49. if total_energy > gain_energy:
50.     print(f"Current energy: {total_energy}.")
51.     if total_profit >= 0:
52.         print("Day completed!")
53.         print(f"Coins: {profit}")
54.         print(f"Energy: {total_energy}")
55.     else:
56.         print(f"Closed! Cannot afford {even}.")
57.
RAW Paste Data