Advertisement
DiYane

Brend Factory

Sep 19th, 2023
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. import sys
  2.  
  3. entrance = input().split("|")
  4.  
  5. energy = 100
  6. coins = 100
  7.  
  8. for event in entrance:
  9.     split = event.split("-")
  10.  
  11.     if split[0] == "rest":
  12.         energy_from = int(split[1])
  13.  
  14.         if 100 - energy < energy_from:
  15.             energy_from = 100 - energy
  16.  
  17.         energy += energy_from
  18.         print(f"You gained {energy_from} energy.")
  19.         print(f"Current energy: {energy}.")
  20.     elif split[0] == "order":
  21.         earn = int(split[1])
  22.  
  23.         if energy >= 30:
  24.             coins += earn
  25.             energy -= 30
  26.             print(f"You earned {earn} coins.")
  27.         else:
  28.             energy += 50
  29.             print("You had to rest!")
  30.     else:
  31.         expense = int(split[1])
  32.         if coins >= expense:
  33.             print(f"You bought {str(split[0])}.")
  34.             coins -= expense
  35.         else:
  36.             print(f"Closed! Cannot afford {str(split[0])}.")
  37.             sys.exit()
  38.  
  39. print("Day completed!")
  40. print(f"Coins: {coins}")
  41. print(f"Energy: {energy}")
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement