Maxim_01

Untitled

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