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

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

Към профила на Николета Бейска

Резултати

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

Код

def calculate_final_vector(starting_point, colors):
end_point = list(starting_point)
color_table = {"C0FFC0": "x-", "FFFFC0": "y-", "FFC0C0": "x+", "C0C0FF": "y+", "00C000": "x+", "C0C000": "y+",
"C00000": "x-", "0000C0": "y-", "FFFFFF": "none", "000000": "fin"}
for color in colors:
match color_table[color.upper()]:
case "x+":
end_point[0] += 1
case "x-":
end_point[0] -= 1
case "y+":
end_point[1] += 1
case "y-":
end_point[1] -= 1
case "fin":
break
return tuple(end_point)

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

........
----------------------------------------------------------------------
Ran 8 tests in 0.090s

OK

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

Николета обнови решението на 24.10.2022 23:40 (преди около 2 години)

+def calculate_final_vector(starting__point, colors):
+ starting_point= list(starting__point)
+ color_table={"C0FFC0": "x-", "FFFFC0": "y-", "FFC0C0": "x+", "C0C0FF": "y+", "00C000": "x+", "C0C000": "y+",
+ "C00000": "x-", "0000C0": "y-", "FFFFFF": "none", "000000": "fin"}
+ for color in colors:
+ match color_table[color.upper()]:
+ case "x+":
+ starting_point[0] += 1
+ case "x-":
+ starting_point[0] -= 1
+ case "y+":
+ starting_point[1] += 1
+ case "y-":
+ starting_point[1] -= 1
+ case "fin":
+ return tuple(starting_point)
+ return tuple(starting_point)

Николета обнови решението на 25.10.2022 11:12 (преди около 2 години)

-def calculate_final_vector(starting__point, colors):
- starting_point= list(starting__point)
- color_table={"C0FFC0": "x-", "FFFFC0": "y-", "FFC0C0": "x+", "C0C0FF": "y+", "00C000": "x+", "C0C000": "y+",
+def calculate_final_vector(starting_point, colors):
+ new_starting_point = list(starting_point)
+ color_table = {"C0FFC0": "x-", "FFFFC0": "y-", "FFC0C0": "x+", "C0C0FF": "y+", "00C000": "x+", "C0C000": "y+",
"C00000": "x-", "0000C0": "y-", "FFFFFF": "none", "000000": "fin"}
for color in colors:
match color_table[color.upper()]:
case "x+":
- starting_point[0] += 1
+ new_starting_point[0] += 1
case "x-":
- starting_point[0] -= 1
+ new_starting_point[0] -= 1
case "y+":
- starting_point[1] += 1
+ new_starting_point[1] += 1
case "y-":
- starting_point[1] -= 1
+ new_starting_point[1] -= 1
case "fin":
- return tuple(starting_point)
- return tuple(starting_point)
+ break
+ return tuple(new_starting_point)

Николета обнови решението на 25.10.2022 11:13 (преди около 2 години)

def calculate_final_vector(starting_point, colors):
- new_starting_point = list(starting_point)
+ end_point = list(starting_point)
color_table = {"C0FFC0": "x-", "FFFFC0": "y-", "FFC0C0": "x+", "C0C0FF": "y+", "00C000": "x+", "C0C000": "y+",
- "C00000": "x-", "0000C0": "y-", "FFFFFF": "none", "000000": "fin"}
+ "C00000": "x-", "0000C0": "y-", "FFFFFF": "none", "000000": "fin"}
for color in colors:
match color_table[color.upper()]:
case "x+":
- new_starting_point[0] += 1
+ end_point[0] += 1
case "x-":
- new_starting_point[0] -= 1
+ end_point[0] -= 1
case "y+":
- new_starting_point[1] += 1
+ end_point[1] += 1
case "y-":
- new_starting_point[1] -= 1
+ end_point[1] -= 1
case "fin":
break
- return tuple(new_starting_point)
+ return tuple(end_point)