Advertisement
Spocoman

09. Moving Target

Feb 12th, 2022
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. targets = [int(x) for x in input().split(' ')]
  2. commands = input()
  3.  
  4. while commands != 'End':
  5.     current = commands.split(' ')
  6.     command = current[0]
  7.     index = int(current[1])
  8.  
  9.     if command == 'Shoot':
  10.         if 0 <= index < len(targets):
  11.             power = int(current[2])
  12.             targets[index] -= power
  13.             if targets[index] <= 0:
  14.                 del targets[index]
  15.  
  16.     elif command == 'Add':
  17.         value = int(current[2])
  18.         if 0 <= index < len(targets):
  19.             targets.insert(index, value)
  20.         else:
  21.             print('Invalid placement!')
  22.  
  23.     elif command == 'Strike':
  24.         radius = int(current[2])
  25.         start_index = index - radius
  26.         if start_index >= 0 and index + radius < len(targets) - 1:
  27.             del targets[start_index: start_index + radius * 2 + 1]
  28.         else:
  29.             print('Strike missed!')
  30.  
  31.     commands = input()
  32.  
  33. targets = [str(x) for x in targets]
  34. print('|'.join(targets))
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement