Advertisement
bl00dt3ars

Moving Target

Jun 16th, 2021
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. targets = [int(x) for x in input().split()]
  2. command = input().split()
  3.  
  4. while not command[0] == "End":
  5.     action, index, power = command[0], int(command[1]), int(command[2])
  6.  
  7.     if action == "Shoot" and 0 <= index < len(targets):
  8.         targets[index] -= power
  9.         if targets[index] <= 0:
  10.             targets.pop(index)
  11.  
  12.     elif action == "Add":
  13.         if 0 <= index < len(targets):
  14.             targets.insert(index, power)
  15.         else:
  16.             print("Invalid placement!")
  17.  
  18.     elif action == "Strike":
  19.         if 0 <= index + power < len(targets) and 0 <= index - power < len(targets):
  20.             targets = targets[:index - power] + targets[index + power + 1:]
  21.         else:
  22.             print("Strike missed!")
  23.            
  24.     command = input().split()
  25.  
  26. print(*targets, sep="|")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement