Кристиан обнови решението на 20.10.2022 16:40 (преди около 2 години)
+def calculate_final_vector(start_coordinates, colors):
+ coordinates = list(start_coordinates)
+ for color in colors:
+ color = str(color.upper())
+ if color == "C0FFC0": #light green
+ coordinates[0] += -1
+ elif color == "00C000": #dark green
+ coordinates[0] += 1
+ elif color == "FFFFC0": #light yellow
+ coordinates[1] += -1
+ elif color == "C0C000": #dark yellow
+ coordinates[1] += 1
+ elif color == "FFC0C0": #light red
+ coordinates[0] -= -1
+ elif color == "C00000": #dark red
+ coordinates[0] -= 1
+ elif color == "C0C0FF": #ligth blue
+ coordinates[1] -= -1
+ elif color == "0000C0": #dark blue
+ coordinates[1] -= 1
+ elif color == "000000": #black
+ return tuple(coordinates)
+ elif color == "FFFFFF": #white
+ continue
+ return tuple(coordinates)
Единствената забележка е, че color.upper()
връща str така или иначе. "Кастването" е излишно