Ангел обнови решението на 24.10.2022 17:00 (преди около 2 години)
+import string
Това е излишно. Не го използваш.
+
+LIGHT_GREEN = 'C0FFC0'
+LIGHT_YELLOW = 'FFFFC0'
+LIGHT_RED = 'FFC0C0'
+LIGHT_BLUE = 'C0C0FF'
+
+DARK_GREEN = '00C000'
+DARK_YELLOW = 'C0C000'
+DARK_RED = 'C00000'
+DARK_BLUE = '0000C0'
+
+WHITE = "FFFFFF"
+BLACK = "000000"
+
+# Зелено - надясно ( x + 1)
+# Жълто - нагоре (y + 1)
+# Червено - наляво (x - 1)
+# Синьо - надолу (y - 1)
+
+# for more unit tests: https://pastebin.com/FJcWPmZ5
+
+
+def calculate_final_vector(coordinates, movement):
+ acordinates = list(coordinates)
+
+ for move in movement:
+ move = str(move).upper()
+ if move == LIGHT_YELLOW:
+ acordinates[1] = acordinates[1] - 1
+ elif move == DARK_YELLOW:
+ acordinates[1] = acordinates[1] + 1
+ elif move == LIGHT_GREEN:
+ acordinates[0] = acordinates[0] - 1
+ elif move == DARK_GREEN:
+ acordinates[0] = acordinates[0] + 1
+ elif move == LIGHT_BLUE:
+ acordinates[1] = acordinates[1] + 1
+ elif move == DARK_BLUE:
+ acordinates[1] = acordinates[1] - 1
+ elif move == LIGHT_RED:
+ acordinates[0] = acordinates[0] + 1
+ elif move == DARK_RED:
+ acordinates[0] = acordinates[0] - 1
+ elif move == BLACK:
+ break
+ else:
+ continue
+
+ temp = tuple(acordinates)
temp
е излишно. Може просто:
return tuple(acordinates)
+ return temp