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
Log in om je inzendingsgeschiedenis te zien
InloggenLog in om de AI-mentor te gebruiken
InloggenVisible tests
1
Input
1, 2, 3Expected
"Cat B"2
Input
1, 3, 2Expected
"Mouse C"3
Input
2, 5, 3Expected
"Cat A"4
Input
5, 5, 5Expected
"Mouse C"5
Input
10, 20, 15Expected
"Mouse C"6
Input
-5, 5, 5Expected
"Cat B"Focus radio
Paused · SomaFM · Fluid