Advertisement
pacho_the_python

Untitled

Feb 13th, 2022
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. targets = list(map(int, input().split(" ")))
  2.  
  3. command = input().split()
  4.  
  5. while True:
  6.     if command[0] == "End":
  7.  
  8.         break
  9.  
  10.     if command[0] == "Shoot":
  11.         index = int(command[1])
  12.         power = int(command[2])
  13.         if 0 <= index < len(targets):
  14.             targets[index] -= power
  15.             if targets[index] <= 0:
  16.                 targets.pop(index)
  17.  
  18.     elif command[0] == "Add":
  19.         add_index = int(command[1])
  20.         value = int(command[2])
  21.         if 0 <= add_index < len(targets):
  22.             targets.insert(add_index, value)
  23.         else:
  24.             print("Invalid placement!")
  25.  
  26.     elif command[0] == "Strike":
  27.         strike_index = int(command[1])
  28.         radius = int(command[2])
  29.         left_strike = strike_index - radius
  30.         right_strike = strike_index + radius
  31.         if 0 <= left_strike and right_strike < len(targets):
  32.             targets = targets[0: left_strike] + targets[right_strike + 1::]
  33.         else:
  34.             print("Strike missed!")
  35.     command = input().split()
  36.  
  37. result = [str(target) for target in targets]
  38.  
  39. print("|".join(result))
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement