Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. targets_list = list(map(int, input().split())) # 24 50 36 70
  2.  
  3. while True:
  4.     command = input()
  5.     if command == "End":
  6.         break
  7.     if command.isdigit():
  8.         target_index = int(command)
  9.         if target_index < len(targets_list):
  10.             shot_target = int(targets_list[target_index])
  11.             targets_list.pop(target_index)
  12.             targets_list.insert(target_index, int(-1))
  13.             for i, target in enumerate(targets_list):
  14.                 if target == -1:
  15.                     continue
  16.                 elif shot_target >= target:
  17.                     targets_list[i] += shot_target
  18.                 elif shot_target < target:
  19.                     targets_list[i] -= int(shot_target)
  20.         else:
  21.             continue
  22. count = 0
  23. for t in targets_list:
  24.     if t == -1:
  25.         count += 1
  26. print(f"Shot targets: {count}", end=" -> ")
  27. targets_list = list(map(str, targets_list))
  28. print(" ".join(targets_list))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement