Advertisement
pacho_the_python

Untitled

Feb 16th, 2022
92
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.         break
  8.  
  9.     if command[0] == "Shoot":
  10.         index = int(command[1])
  11.         power = int(command[2])
  12.         if 0 <= index < len(targets):
  13.             targets[index] -= power
  14.             if targets[index] <= 0:
  15.                 targets.pop(index)
  16.  
  17.     elif command[0] == "Add":
  18.         add_index = int(command[1])
  19.         value = int(command[2])
  20.         if 0 <= add_index < len(targets):
  21.             targets.insert(add_index, value)
  22.         else:
  23.             print("Invalid placement!")
  24.  
  25.     elif command[0] == "Strike":
  26.         strike_index = int(command[1])
  27.         radius = int(command[2])
  28.         left_strike = strike_index - radius
  29.         right_strike = strike_index + radius
  30.         if 0 <= left_strike and right_strike < len(targets):
  31.             targets = targets[0: left_strike] + targets[right_strike + 1:]
  32.         else:
  33.             print("Strike missed!")
  34.     command = input().split()
  35.  
  36. result = [str(target) for target in targets]
  37.  
  38. print("|".join(result))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement