Решение на Навигация на Piet от Огнян Йончев

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

Към профила на Огнян Йончев

Резултати

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

Код

# All colors we may have in the painting.
colors = {
'C0FFC0': [-1, 0],
'00C000': [1, 0],
'FFFFC0': [0, -1],
'C0C000': [0, 1],
'FFC0C0': [1, 0],
'C00000': [-1, 0],
'C0C0FF': [0, 1],
'0000C0': [0, -1],
'FFFFFF': [0, 0],
'000000': [-2, -2],
}
# Return the last coordinates of the point.
def calculate_final_vector(coordinates, list_of_colors):
x, y = coordinates
for color in list_of_colors:
if color == '000000':
break
elif color.upper() in colors:
x += colors[color.upper()][0]
y += colors[color.upper()][1]
else:
print('Wrong color!')
return None
return (x, y)

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

........
----------------------------------------------------------------------
Ran 8 tests in 0.112s

OK

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

Огнян обнови решението на 23.10.2022 00:27 (преди над 1 година)

+"""All colors we may have in the painting."""
+colors = {
+ 'C0FFC0': [-1, 0],
+ '00C000': [1, 0],
+ 'FFFFC0': [0, -1],
+ 'C0C000': [0, +1],
+ 'FFC0C0': [1, 0],
+ 'C00000': [-1, 0],
+ 'C0C0FF': [0, 1],
+ '0000C0': [0, -1],
+ 'FFFFFF': [0, 0],
+ '000000': [-2, -2],
+}
+
+
+def calculate_final_vector(coordinates, list_of_colors):
+ """Return the last coordinates of the point."""
+ x = coordinates[0]
+ y = coordinates[1]
+ for color in list_of_colors:
+ if color == '000000':
+ break
+ elif color.upper() in colors:
+ x += colors[color.upper()][0]
+ y += colors[color.upper()][1]
+ else:
+ print('Wrong color!')
+ return None
+ return (x, y)

Огнян обнови решението на 24.10.2022 22:08 (преди над 1 година)

-"""All colors we may have in the painting."""
+# All colors we may have in the painting.
colors = {
'C0FFC0': [-1, 0],
'00C000': [1, 0],
'FFFFC0': [0, -1],
- 'C0C000': [0, +1],
+ 'C0C000': [0, 1],
'FFC0C0': [1, 0],
'C00000': [-1, 0],
'C0C0FF': [0, 1],
'0000C0': [0, -1],
'FFFFFF': [0, 0],
'000000': [-2, -2],
}
+# Return the last coordinates of the point.
def calculate_final_vector(coordinates, list_of_colors):
- """Return the last coordinates of the point."""
- x = coordinates[0]
- y = coordinates[1]
+ x, y = coordinates
for color in list_of_colors:
if color == '000000':
break
elif color.upper() in colors:
x += colors[color.upper()][0]
y += colors[color.upper()][1]
else:
print('Wrong color!')
return None
return (x, y)
+