Решение на Навигация на Piet от Минчо Христов

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

Към профила на Минчо Христов

Резултати

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

Код

def calculate_final_vector(coordinates, colors):
next_coordinates = (coordinates[0], coordinates[1])
for color in colors:
if color.upper() == "C0FFC0":
next_coordinates = (coordinates[0] - 1, coordinates[1])
elif color.upper() == "00C000":
next_coordinates = (coordinates[0] + 1, coordinates[1])
elif color.upper() == "FFFFC0":
next_coordinates = (coordinates[0], coordinates[1] - 1)
elif color.upper() == "C0C000":
next_coordinates = (coordinates[0], coordinates[1] + 1)
elif color.upper() == "FFC0C0":
next_coordinates = (coordinates[0] + 1, coordinates[1])
elif color.upper() == "C00000":
next_coordinates = (coordinates[0] - 1, coordinates[1])
elif color.upper() == "C0C0FF":
next_coordinates = (coordinates[0], coordinates[1] - 1)
elif color.upper() == "0000C0":
next_coordinates = (coordinates[0], coordinates[1] + 1)
elif color.upper() == "000000":
return next_coordinates
coordinates = next_coordinates
return next_coordinates

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

F..FFF..
======================================================================
FAIL: test_a_metric_shit_ton_of_hexes (test.TestCalculateFinalVector)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
AssertionError: Tuples differ: (-42, -158) != (-42, 42)

First differing element 1:
-158
42

- (-42, -158)
+ (-42, 42)

======================================================================
FAIL: test_mixed_case (test.TestCalculateFinalVector)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
AssertionError: Tuples differ: (2, -2) != (2, 2)

First differing element 1:
-2
2

- (2, -2)
?     -

+ (2, 2)

======================================================================
FAIL: test_negative_step (test.TestCalculateFinalVector)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
AssertionError: Tuples differ: (0, -1) != (0, 1)

First differing element 1:
-1
1

- (0, -1)
?     -

+ (0, 1)

======================================================================
FAIL: test_positive_step (test.TestCalculateFinalVector)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
AssertionError: Tuples differ: (0, 1) != (0, -1)

First differing element 1:
1
-1

- (0, 1)
+ (0, -1)
?     +


----------------------------------------------------------------------
Ran 8 tests in 0.114s

FAILED (failures=4)

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

Минчо обнови решението на 20.10.2022 00:13 (преди около 2 години)

+def calculate_final_vector(cord, cols):
+ next1 = cord
+ for col in cols:
+ if col.upper() == "C0FFC0":
+ next1 = cord[0]-1, cord[1]
+ elif col.upper() == "00C000":
+ next1 = cord[0] + 1, cord[1]
+ elif col.upper() == "FFFFC0":
+ next1 = cord[0], cord[1]-1
+ elif col.upper() == "C0C000":
+ next1 = cord[0], cord[1]+1
+ elif col.upper() == "FFC0C0":
+ next1 = cord[0]+1, cord[1]
+ elif col.upper() == "C00000":
+ next1 = cord[0]-1, cord[1]
+ elif col.upper() == "C0C0FF":
+ next1 = cord[0], cord[1]-1
+ elif col.upper() == "0000C0":
+ next1 = cord[0], cord[1]+1
+ elif col.upper() == "000000":
+ return next1
+ cord = next1
+ return next1

Минчо обнови решението на 20.10.2022 00:32 (преди около 2 години)

+
def calculate_final_vector(cord, cols):
next1 = cord
for col in cols:
if col.upper() == "C0FFC0":
next1 = cord[0]-1, cord[1]
elif col.upper() == "00C000":
next1 = cord[0] + 1, cord[1]
elif col.upper() == "FFFFC0":
next1 = cord[0], cord[1]-1
elif col.upper() == "C0C000":
next1 = cord[0], cord[1]+1
elif col.upper() == "FFC0C0":
next1 = cord[0]+1, cord[1]
elif col.upper() == "C00000":
next1 = cord[0]-1, cord[1]
elif col.upper() == "C0C0FF":
next1 = cord[0], cord[1]-1
elif col.upper() == "0000C0":
next1 = cord[0], cord[1]+1
elif col.upper() == "000000":
return next1
cord = next1
return next1

Минчо обнови решението на 20.10.2022 00:39 (преди около 2 години)

-def calculate_final_vector(cord, cols):
- next1 = cord
+def calculate_final_vector(coordinates, colors):
- for col in cols:
+ next_coordinates = coordinates
- if col.upper() == "C0FFC0":
+ for color in colors:
- next1 = cord[0]-1, cord[1]
+ if color.upper() == "C0FFC0":
- elif col.upper() == "00C000":
+ next_coordinates = coordinates[0] - 1, coordinates[1]
- next1 = cord[0] + 1, cord[1]
+ elif color.upper() == "00C000":
- elif col.upper() == "FFFFC0":
+ next_coordinates = coordinates[0] + 1, coordinates[1]
- next1 = cord[0], cord[1]-1
+ elif color.upper() == "FFFFC0":
- elif col.upper() == "C0C000":
+ next_coordinates = coordinates[0], coordinates[1] - 1
- next1 = cord[0], cord[1]+1
+ elif color.upper() == "C0C000":
- elif col.upper() == "FFC0C0":
+ next_coordinates = coordinates[0], coordinates[1] + 1
- next1 = cord[0]+1, cord[1]
+ elif color.upper() == "FFC0C0":
- elif col.upper() == "C00000":
+ next_coordinates = coordinates[0] + 1, coordinates[1]
- next1 = cord[0]-1, cord[1]
+ elif color.upper() == "C00000":
- elif col.upper() == "C0C0FF":
+ next_coordinates = coordinates[0] - 1, coordinates[1]
- next1 = cord[0], cord[1]-1
+ elif color.upper() == "C0C0FF":
- elif col.upper() == "0000C0":
+ next_coordinates = coordinates[0], coordinates[1] - 1
- next1 = cord[0], cord[1]+1
+ elif color.upper() == "0000C0":
- elif col.upper() == "000000":
+ next_coordinates = coordinates[0], coordinates[1] + 1
- return next1
+ elif color.upper() == "000000":
- cord = next1
+ return next_coordinates
- return next1
+ coordinates = next_coordinates
+ return next_coordinates

Минчо обнови решението на 23.10.2022 00:58 (преди около 2 години)

def calculate_final_vector(coordinates, colors):
- next_coordinates = coordinates
+ next_coordinates = (coordinates[0], coordinates[1])
for color in colors:
if color.upper() == "C0FFC0":
- next_coordinates = coordinates[0] - 1, coordinates[1]
+ next_coordinates = (coordinates[0] - 1, coordinates[1])
elif color.upper() == "00C000":
- next_coordinates = coordinates[0] + 1, coordinates[1]
+ next_coordinates = (coordinates[0] + 1, coordinates[1])
elif color.upper() == "FFFFC0":
- next_coordinates = coordinates[0], coordinates[1] - 1
+ next_coordinates = (coordinates[0], coordinates[1] - 1)
elif color.upper() == "C0C000":
- next_coordinates = coordinates[0], coordinates[1] + 1
+ next_coordinates = (coordinates[0], coordinates[1] + 1)
elif color.upper() == "FFC0C0":
- next_coordinates = coordinates[0] + 1, coordinates[1]
+ next_coordinates = (coordinates[0] + 1, coordinates[1])
elif color.upper() == "C00000":
- next_coordinates = coordinates[0] - 1, coordinates[1]
+ next_coordinates = (coordinates[0] - 1, coordinates[1])
elif color.upper() == "C0C0FF":
- next_coordinates = coordinates[0], coordinates[1] - 1
+ next_coordinates = (coordinates[0], coordinates[1] - 1)
elif color.upper() == "0000C0":
- next_coordinates = coordinates[0], coordinates[1] + 1
+ next_coordinates = (coordinates[0], coordinates[1] + 1)
elif color.upper() == "000000":
return next_coordinates
coordinates = next_coordinates
return next_coordinates

Като изключим, че можеш да минеш без "next_coordinates" (в някакъв момент така или иначе правиш coordinates = next_coordinates), нямам за какво да се хвана.
Но това не е забележка, която изисква да предадеш ново решение, просто обратна връзка. :)