Advertisement
pacho_the_python

john_the_archer

Aug 12th, 2022
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.90 KB | None | 0 0
  1. targets = list(map(int, input().split("|")))
  2.  
  3. data = input().split(" ")
  4.  
  5.  
  6. def start_end_left_right(some_string: str):
  7.     left_right = some_string.split("@")[0]
  8.     start = some_string.split("@")[1]
  9.     targets_range = some_string.split("@")[2]
  10.     return left_right, start, targets_range
  11.  
  12.  
  13. def shoot_left(num_1, num_2, target_list):
  14.     i = num_1
  15.     while True:
  16.         if num_2 < 0:
  17.             break
  18.  
  19.         if i + 1 == len(target_list):
  20.             i = -1
  21.         i += 1
  22.         num_2 -= 1
  23.        
  24.     return i, target_list
  25.  
  26.  
  27. def shoot_right(num_1, num_2, target_list):
  28.     i = num_1
  29.     while True:
  30.         if num_2 == 0:
  31.             break
  32.  
  33.         if i < 0:
  34.             i = len(target_list)
  35.         else:
  36.             num_2 -= 1
  37.         i -= 1
  38.        
  39.     return i, target_list
  40.  
  41.  
  42. score = 0
  43.  
  44. while True:
  45.     if data[0] == "Game":
  46.         break
  47.     if data[0] == "Shoot":
  48.         shoot_data = data[1]
  49.         direction = start_end_left_right(shoot_data)[0]
  50.         start_index = int(start_end_left_right(shoot_data)[1])
  51.         number_of_targets = int(start_end_left_right(shoot_data)[2])
  52.  
  53.         if start_index >= len(targets):
  54.             data = input().split(" ")
  55.             continue
  56.  
  57.         if direction == "Left":
  58.             targets = shoot_left(start_index, number_of_targets, targets)[1]
  59.             index = shoot_left(start_index, number_of_targets, targets)[0]
  60.             targets[index] -= 5
  61.             score += 5
  62.  
  63.         elif direction == "Right":
  64.             targets = shoot_right(start_index, number_of_targets, targets)[1]
  65.             index = shoot_right(start_index, number_of_targets, targets)[0]
  66.             targets[index] -= 5
  67.             score += 5
  68.  
  69.     elif data[0] == "Reverse":
  70.         targets.reverse()
  71.  
  72.     data = input().split(" ")
  73.  
  74. print(" - ".join(map(str, targets)))
  75. print(f"John finished the archery tournament with {score} points!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement