Решение на Навигация на Piet от Виктор Боев

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

Към профила на Виктор Боев

Резултати

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

Код

def calculate_final_vector(StartPoint, colours) :
first, second = StartPoint
for colour in colours:
match(colour.upper()) :
case '00C000' : # greenDark
first = first + 1
case 'C0FFC0' :
first = first - 1
case 'C0C000' : # yellowDark
second = second + 1
case 'FFFFC0' :
second = second - 1
case 'FFC0C0' : # redLight
first = first + 1
case 'C00000' :
first = first - 1
case 'C0C0FF' : # blueLight
second = second + 1
case '0000C0' :
second = second - 1
case 'FFFFFF' : # white
continue
case '000000' : # black
break
case _:
print("Error")
return -1, -1
return first, second

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

........
----------------------------------------------------------------------
Ran 8 tests in 0.086s

OK

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

Виктор обнови решението на 21.10.2022 10:59 (преди около 2 години)

+def calculate_final_vector(startPoint, colours) :
+ (first, second) = startPoint
+ for colour in colours:
+ match(colour.upper()) :
+ case '00C000' : # greenDark
+ first = first + 1
+ case 'C0FFC0' :
+ first = first - 1
+ case 'C0C000' : # yellowDark
+ second = second + 1
+ case 'FFFFC0' :
+ second = second - 1
+ case 'FFC0C0' : # redLight
+ first = first + 1
+ case 'C00000' :
+ first = first - 1
+ case 'C0C0FF' : # blueLight
+ second = second + 1
+ case '0000C0' :
+ second = second - 1
+ case 'FFFFFF' : # white
+ continue
+ case '000000' : # black
+ break
+ case _:
+ print("Error")
+ return (-1, -1)
+ return (first, second)

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

-def calculate_final_vector(startPoint, colours) :
- (first, second) = startPoint
+def calculate_final_vector(StartPoint, colours) :
+ first, second = StartPoint
for colour in colours:
match(colour.upper()) :
case '00C000' : # greenDark
first = first + 1
case 'C0FFC0' :
first = first - 1
case 'C0C000' : # yellowDark
second = second + 1
case 'FFFFC0' :
second = second - 1
case 'FFC0C0' : # redLight
first = first + 1
case 'C00000' :
first = first - 1
case 'C0C0FF' : # blueLight
second = second + 1
case '0000C0' :
second = second - 1
case 'FFFFFF' : # white
continue
case '000000' : # black
break
case _:
print("Error")
- return (-1, -1)
- return (first, second)
+ return -1, -1
+ return first, second