Advertisement
Guest User

02. Shoot for the Win

a guest
Apr 7th, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.39 KB | None | 0 0
  1. targets = list(map(int, input().split()))
  2. indexes = input()
  3.  
  4. targets_count = 0
  5.  
  6. while True:
  7.     if indexes == "End":
  8.         break
  9.     else:
  10.         index = int(indexes)
  11.         if 0 <= index < len(targets):
  12.             current_target = targets[index]
  13.             target_shot = False
  14.             for target in targets:
  15.                 if target != -1:
  16.                     if target > current_target:
  17.                         target_index = targets.index(target)
  18.                         target -= current_target
  19.                         targets[target_index] = target
  20.                     elif target < current_target:
  21.                         target_index = targets.index(target)
  22.                         target += current_target
  23.                         targets[target_index] = target
  24.                     else:
  25.                         if target_shot:
  26.                             target_index = targets.index(target)
  27.                             target += current_target
  28.                             targets[target_index] = target
  29.                         else:
  30.                             targets[index] = -1
  31.                             target_shot = True
  32.                 else:
  33.                     continue
  34.             targets_count += 1
  35.  
  36.     indexes = input()
  37.  
  38. targets = [str(target) for target in targets]
  39. print(f"Shot targets: {targets_count} -> ", end="")
  40. print(" ".join(targets))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement