Advertisement
Spocoman

03. Moving Target

Nov 8th, 2023
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. targets = list(map(int, input().split(' ')))
  2. command = input()
  3.  
  4. while command != "End":
  5.     command, index, value = command.split(' ')
  6.     index = int(index)
  7.     value = int(value)
  8.     if command == "Shoot":
  9.         if 0 <= index < len(targets):
  10.             targets[index] -= value
  11.             if targets[index] <= 0:
  12.                 targets.pop(index)
  13.     elif command == "Add":
  14.         if 0 <= index < len(targets):
  15.             targets.insert(index, value)
  16.         else:
  17.             print("Invalid placement!")
  18.     elif command == "Strike":
  19.         if index - value >= 0 and index + value < len(targets):
  20.             del targets[index - value: value + index + 1]
  21.         else:
  22.             print("Strike missed!")
  23.  
  24.     command = input()
  25.  
  26. print('|'.join(map(str, targets)))
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement