Advertisement
Osiris1002

Shoot for the Win

Feb 12th, 2024
1,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. targets = list(map(int, input().split()))
  2. def shoot_target(index):
  3.     if 0 <= index < len(targets) and targets[index] != -1:
  4.         shot_value = targets[index]
  5.         targets[index] = -1
  6.         for i in range(len(targets)):
  7.             if targets[i] > shot_value:
  8.                 targets[i] -= shot_value
  9.             elif targets[i] != -1:
  10.                 targets[i] += shot_value
  11.  
  12. while True:
  13.     command = input()
  14.     if command == "End":
  15.         break
  16.     index = int(command)
  17.     shoot_target(index)
  18.  
  19. shot_targets = [target for target in targets if target == -1]
  20.  
  21. print(f"Shot targets: {len(shot_targets)} -> {' '.join(map(str, targets))}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement