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

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

Към профила на Мария Кукова

Резултати

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

Код

def calculate_final_vector(starting_point, color_list):
x, y = starting_point
for color in color_list:
color = color.upper()
match color:
# light green
case 'C0FFC0':
x -= 1
# dark green
case '00C000':
x += 1
# light yellow
case 'FFFFC0':
y -= 1
# dark yellow
case 'C0C000':
y += 1
# light red
case 'FFC0C0':
x += 1
# dark red
case 'C00000':
x -= 1
# light blue
case 'C0C0FF':
y += 1
# dark blue
case '0000C0':
y -= 1
# black
case '000000':
break
return x ,y

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

........
----------------------------------------------------------------------
Ran 8 tests in 0.093s

OK

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

Мария обнови решението на 24.10.2022 18:04 (преди около 2 години)

+def calculate_final_vector(starting_point, color_list):
+ x = starting_point[0]
+ y = starting_point[1]
+ for color in color_list:
+ color = color.upper()
+ match color:
+ # light green
+ case 'C0FFC0':
+ x -= 1
+ # dark green
+ case '00C000':
+ x += 1
+ # light yellow
+ case 'FFFFC0':
+ y -= 1
+ # dark yellow
+ case 'C0C000':
+ y += 1
+ # light red
+ case 'FFC0C0':
+ x += 1
+ # dark red
+ case 'C00000':
+ x -= 1
+ # light blue
+ case 'C0C0FF':
+ y += 1
+ # dark blue
+ case '0000C0':
+ y -= 1
+ # black
+ case '000000':
+ print("end game")
+ break
+
+ result = (x, y)
+ return result

Мария обнови решението на 24.10.2022 18:05 (преди около 2 години)

def calculate_final_vector(starting_point, color_list):
x = starting_point[0]
y = starting_point[1]
for color in color_list:
color = color.upper()
match color:
# light green
case 'C0FFC0':
x -= 1
# dark green
case '00C000':
x += 1
# light yellow
case 'FFFFC0':
y -= 1
# dark yellow
case 'C0C000':
y += 1
# light red
case 'FFC0C0':
x += 1
# dark red
case 'C00000':
x -= 1
# light blue
case 'C0C0FF':
y += 1
# dark blue
case '0000C0':
y -= 1
# black
case '000000':
- print("end game")
break
result = (x, y)
return result

Мария обнови решението на 25.10.2022 00:02 (преди около 2 години)

def calculate_final_vector(starting_point, color_list):
- x = starting_point[0]
- y = starting_point[1]
+ x, y = starting_point
for color in color_list:
color = color.upper()
match color:
# light green
case 'C0FFC0':
x -= 1
# dark green
case '00C000':
x += 1
# light yellow
case 'FFFFC0':
y -= 1
# dark yellow
case 'C0C000':
y += 1
# light red
case 'FFC0C0':
x += 1
# dark red
case 'C00000':
x -= 1
# light blue
case 'C0C0FF':
y += 1
# dark blue
case '0000C0':
y -= 1
# black
case '000000':
break
- result = (x, y)
- return result
+ return x ,y