Spocoman

02. Shoot for the Win

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