Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def shoot_index(start):
- for _ in range(1, length + 1):
- if start == len(targets_int) - 1:
- start = 0
- continue
- start += 1
- return start
- def shoot_index_rev(start):
- for _ in range(length, 0, -1):
- if start == 0:
- start = len(targets_int) - 1
- continue
- start -= 1
- return start
- targets = input().split('|')
- targets_int = list(map(int, targets))
- points = 0
- while True:
- commands = input().split('@') # comand start/i length
- command = commands[0]
- if command == "Game over":
- break
- if command == "Shoot Left":
- start = int(commands[1])
- length = int(commands[2])
- if start <= len(targets_int) - 1:
- start_shoot = shoot_index_rev(start)
- if targets_int[start_shoot] < 5:
- points += 5
- targets_int[start_shoot] = 0
- else:
- points += 5
- targets_int[start_shoot] -= 5
- else:
- continue
- elif command == "Shoot Right":
- start = int(commands[1])
- length = int(commands[2])
- if start <= len(targets_int) - 1:
- start_shoot = shoot_index(start)
- if targets_int[start_shoot] < 5:
- points += 5
- targets_int[start_shoot] = 0
- else:
- points += 5
- targets_int[start_shoot] -= 5
- else:
- continue
- elif command == "Reverse":
- targets_int.reverse()
- for index, target in enumerate(targets_int):
- if index < len(targets_int) - 1:
- print(target, end=" - ")
- else:
- print(target, end="")
- print()
- print(f"Iskren finished the archery tournament with {points} points!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement