Сузана обнови решението на 20.10.2022 14:36 (преди около 2 години)
+import re
+
+
+def calculate_final_vector(coordinates, list_of_directions):
+ black = '000000'
+ white = 'FFFFFF'
+
+ abscissa_colors = {
+ 'C0FFC0': -1,
+ 'FFC0C0': 1,
+ '00C000': 1,
+ 'C00000': -1
+ }
+
+ ordinate_colors = {
+ 'FFFFC0': -1,
+ 'C0C000': 1,
+ 'C0C0FF': 1,
+ '0000C0': -1
+ }
+
+ directions = [color.upper() for color in list_of_directions]
+
+ for direction in directions:
+ if direction == black:
+ return coordinates
+ if direction in abscissa_colors:
+ coordinates['x'] += abscissa_colors[direction]
+ elif direction in ordinate_colors and direction != white:
+ coordinates['y'] += ordinate_colors[direction]
+ else:
+ continue
+
+ return coordinates
+
+
+start_vector = input()
+match = re.search(r'\((\d+)\, *(\d+)\)', start_vector)
+
+x = int(match.group(1))
+y = int(match.group(2))
+
+start_coordinates = {'x': x, 'y': y}
+
+input_directions = list(input().split(', '))
+list_of_input_directions = [re.search(r'([0-9A-Fa-f]+)', direction).group() for direction in input_directions]
+
+result = calculate_final_vector(start_coordinates, list_of_input_directions)
+
+print(f"({result['x']}, {result['y']})")