Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.83 KB | None | 0 0
  1. targets = list(map(int, input().split("|")))
  2.  
  3. command = input()
  4. points = 0
  5. while command != 'Game over':
  6.     command_list = command.split('@')
  7.     if command_list[0] == 'Shoot Left':
  8.         index_start = int(command_list[1])
  9.         step = int(command_list[2])
  10.         if 0 <= index_start < len(targets):
  11.             index_shoot = index_start - step
  12.             if index_shoot < 0:
  13.                 index_shoot = len(targets) + index_shoot
  14.                 while index_shoot < 0:
  15.                     index_shoot = len(targets) + index_shoot
  16.             if targets[index_shoot] >= 5:
  17.                 targets[index_shoot] -= 5
  18.                 points += 5
  19.             elif 0 <= targets[index_shoot] < 5:
  20.                 points += targets[index_shoot]
  21.                 targets[index_shoot] = 0
  22.  
  23.     elif command_list[0] == 'Shoot Right':
  24.         index_start = int(command_list[1])
  25.         step = int(command_list[2])
  26.         if 0 <= index_start < len(targets):
  27.             index_shoot = index_start + step
  28.             if index_shoot > len(targets) - 1:
  29.                 index_shoot -= len(targets)
  30.                 while index_shoot > len(targets) - 1:
  31.                     index_shoot -= len(targets)
  32.             if targets[index_shoot] >= 5:
  33.                 targets[index_shoot] -= 5
  34.                 points += 5
  35.             elif 0 <= targets[index_shoot] < 5:
  36.                 points += targets[index_shoot]
  37.                 targets[index_shoot] = 0
  38.  
  39.     elif command_list[0] == 'Reverse':
  40.         targets = list(targets[::-1])
  41.     command = input()
  42.  
  43. targets_to_print = ''
  44. for i in range(len(targets)):
  45.     if i == len(targets) - 1:
  46.         targets_to_print += str(targets[i])
  47.     else:
  48.         targets_to_print += str(targets[i]) + ' - '
  49. print(targets_to_print)
  50. print(f'Iskren finished the archery tournament with {points} points!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement