Back to Start
A robot starts at point (0, 0) and follows movement commands. The function judge_circle receives a string moves, where U moves up, D moves down, L moves left, and R moves right. Check whether the robot ends up back at the starting point after all commands. Return True if it returns, otherwise return False.
Примеры
Ввод
["UDLRUD"]Вывод
TrueВвод
["LLRU"]Вывод
FalseВвод
["UD"]Вывод
TrueНужно реализовать
def judge_circle(moves: str) -> bool:
Теги
strings
Connectez-vous pour voir l'historique des soumissions
Se connecterConnectez-vous pour utiliser le Mentor IA
Se connecterVisible tests
1
Input
"UDLRUD"Expected
True2
Input
"LLRU"Expected
False3
Input
"UD"Expected
True4
Input
""Expected
True5
Input
" "Expected
True6
Input
"a"Expected
TrueFocus radio
Paused · SomaFM · Fluid