Решение на Навигация на Piet от Кристиан Какалов

Обратно към всички решения

Към профила на Кристиан Какалов

Резултати

  • 10 точки от тестове
  • 0 бонус точки
  • 10 точки общо
  • 8 успешни тест(а)
  • 0 неуспешни тест(а)

Код

def calculate_final_vector(start_coordinates, colors):
coordinates = list(start_coordinates)
for color in colors:
color = 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)

Лог от изпълнението

........
----------------------------------------------------------------------
Ran 8 tests in 0.085s

OK

История (2 версии и 1 коментар)

Кристиан обнови решението на 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)

Кристиан обнови решението на 24.10.2022 09:15 (преди около 2 години)

def calculate_final_vector(start_coordinates, colors):
coordinates = list(start_coordinates)
for color in colors:
- color = str(color.upper())
+ color = 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)