Skip to content

Instantly share code, notes, and snippets.

@andriiburka
Created February 28, 2020 16:46
Show Gist options
  • Save andriiburka/fb986aa80c0800991daa07b4e1f878ec to your computer and use it in GitHub Desktop.
Save andriiburka/fb986aa80c0800991daa07b4e1f878ec to your computer and use it in GitHub Desktop.
targets_list = list(map(int, input().split("|")))
points = 0
while True:
operations = input()
if "Game over" in operations:
print(" - ".join(str(targets_list).split(', '))[1:-1])
print(f'Iskren finished the archery tournament with {points} points!')
break
elif "Reverse" in operations:
targets_list = targets_list[::-1]
continue
else:
# separating
operations = operations.split("@")
# bools
start_index = int(operations[1])
traverse_len = int(operations[2])
command_is_shoot = 'Shoot' in operations[0].split()[0]
direction_is_left = 'Left' in operations[0].split()[1]
direction_is_right = 'Right' in operations[0].split()[1]
# conditions
if start_index > len(targets_list):
continue
else:
index = 0
if command_is_shoot and direction_is_left:
index = start_index - traverse_len
if index < start_index:
while index < 0:
index += len(targets_list)
targets_list[index] -= 5
elif command_is_shoot and direction_is_right:
index = start_index + traverse_len
if index > len(targets_list):
while index > len(targets_list):
index -= len(targets_list)
targets_list[index] -= 5
if targets_list[index] < 5:
points += targets_list[index]
targets_list[index] = 0
points += 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment