Иван обнови решението на 24.10.2022 23:20 (преди около 2 години)
+def calculate_final_vector(start_point, color_list):
+ x = start_point[0]
Можеш директно да unpack-неш:
x, y = start_point
+ y = start_point[1]
+ for color in color_list:
+ match color.upper():
+ case "C0FFC0": # light green
+ x -= 1
+ case "00C000": # dark green
+ x += 1
+ case "FFFFC0": # light yellow
+ y -= 1
+ case "C0C000": # dark yellow
+ y += 1
+ case "FFC0C0": # light red
+ x += 1
+ case "C00000": # dark red
+ x -= 1
+ case "C0C0FF": # light blue
+ y += 1
+ case "0000C0": # dark blue
+ y -= 1
+ case "FFFFFF": # white
+ pass
+ case "000000": # black
+ break
+ case _: # default because it seems like a normal thing to do
+ break
+
+ return (x, y)
Можеш да пропуснеш скобите.
+
+calculate_final_vector((1, 1), ['00C000', 'C0FFC0', 'C00000', 'FFFFFF', 'C0C000'])
Можеш директно да unpack-неш:
x, y = start_point
Можеш да пропуснеш скобите.