Advertisement
Guest User

Untitled

a guest
Oct 18th, 2021
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. sequence_of_targets = input().split(' ')
  2. sequence_of_targets = [int(x) for x in sequence_of_targets]
  3. command = input()
  4.  
  5. while command != 'End':
  6.     command = command.split(' ')
  7.     action = command[0]
  8.     index = int(command[1])
  9.  
  10.     if action == 'Shoot':
  11.         power = int(command[2])
  12.         if index in range(len(sequence_of_targets)):
  13.             if sequence_of_targets[index] - power > 0:
  14.                 sequence_of_targets[index] -= power
  15.             else:
  16.                 sequence_of_targets.pop(index)
  17.  
  18.     elif action == 'Add':
  19.         value = int(command[2])
  20.         if index in range(len(sequence_of_targets)):
  21.             sequence_of_targets.insert(index, value)
  22.         else:
  23.             print('Invalid placement!')
  24.  
  25.     elif action == 'Strike':
  26.         radius = int(command[2])
  27.         before_radius = index - radius
  28.         after_radius = index + radius
  29.  
  30.         if after_radius in range(len(sequence_of_targets)):
  31.             sequence_of_targets = sequence_of_targets[0:before_radius] + sequence_of_targets[after_radius + 1::]
  32.         else:
  33.             print('Strike missed!')
  34.  
  35.     command = input()
  36.  
  37. result = '|'.join(str(x) for x in sequence_of_targets)
  38. print(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement