Closest Cat Wins
On a number line, two cats run toward the same mouse at the same speed. The function cats_and_a_mouse receives the position of Cat A as x, Cat B as y, and the mouse as z. Compare the distances to the mouse: return Cat A if the first cat is closer, Cat B if the second cat is closer, or Mouse C if the distances are equal.
Примеры
Ввод
1, 2, 3Вывод
"Cat B"Ввод
1, 3, 2Вывод
"Mouse C"Ввод
2, 5, 3Вывод
"Cat A"Нужно реализовать
def cats_and_a_mouse(x: int, y: int, z: int) -> str:
Теги
math
Accedi per vedere la cronologia degli invii
AccediAccedi per usare l'AI Mentor
AccediTests12
Visible tests
Test nascosto 7
Test nascosto 8
Test nascosto 9
Test nascosto 10
Test nascosto 11
Test nascosto 12
They run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.
Focus radio
Paused · SomaFM · Fluid