Стоян обнови решението на 24.10.2022 23:33 (преди около 2 години)
+def calculate_final_vector(starting_point, colors):
+ end_point_coordinates = [starting_point[0], starting_point[1]]
Можеш директно:
end_point_coordinates = list(starting_point)
+ # first coordinate == X, second == Y
+ moves_for_color = {
+ "c0ffc0": (-1, 0), # light green
+ "ffffc0": (0, -1), # light yellow
+ "ffc0c0": (1, 0), # light red
+ "c0c0ff": (0, 1), # light blue
+ "00c000": (1, 0), # dark green
+ "c0c000": (0, 1), # dark yellow
+ "c00000": (-1, 0), # dark red
+ "0000c0": (0, -1), # dark blue
+ "ffffff": (0, 0) # white
+ }
+
+ for color in colors:
+ if color == "000000":
+ return tuple(end_point_coordinates)
+
+ move = moves_for_color[color.lower()]
+ end_point_coordinates[0] += move[0]
+ end_point_coordinates[1] += move[1]
+
+ return tuple(end_point_coordinates)
Можеш директно:
end_point_coordinates = list(starting_point)