Guest User

02. Shoot for the Win - Fundamentals Mid Exam Retake

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