Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. def shoot_index(start):
  2. for _ in range(1, length + 1):
  3. if start == len(targets_int) - 1:
  4. start = 0
  5. continue
  6. start += 1
  7. return start
  8.  
  9.  
  10. def shoot_index_rev(start):
  11. for _ in range(length, 0, -1):
  12. if start == 0:
  13. start = len(targets_int) - 1
  14. continue
  15. start -= 1
  16. return start
  17.  
  18.  
  19. targets = input().split('|')
  20. targets_int = list(map(int, targets))
  21. points = 0
  22. while True:
  23. commands = input().split('@') # comand start/i length
  24. command = commands[0]
  25. if command == "Game over":
  26. break
  27.  
  28. if command == "Shoot Left":
  29. start = int(commands[1])
  30. length = int(commands[2])
  31. if start <= len(targets_int) - 1:
  32. start_shoot = shoot_index_rev(start)
  33. if targets_int[start_shoot] < 5:
  34. points += 5
  35. targets_int[start_shoot] = 0
  36. else:
  37. points += 5
  38. targets_int[start_shoot] -= 5
  39. else:
  40. continue
  41.  
  42. elif command == "Shoot Right":
  43. start = int(commands[1])
  44. length = int(commands[2])
  45. if start <= len(targets_int) - 1:
  46. start_shoot = shoot_index(start)
  47. if targets_int[start_shoot] < 5:
  48. points += 5
  49. targets_int[start_shoot] = 0
  50. else:
  51. points += 5
  52. targets_int[start_shoot] -= 5
  53. else:
  54. continue
  55.  
  56. elif command == "Reverse":
  57. targets_int.reverse()
  58.  
  59. for index, target in enumerate(targets_int):
  60. if index < len(targets_int) - 1:
  61. print(target, end=" - ")
  62. else:
  63. print(target, end="")
  64. print()
  65. print(f"Iskren finished the archery tournament with {points} points!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement