You are viewing a single comment's thread. Return to all comments →
Here is my quick and easy Python solution. If the cats are the same distance away, we return "Mouse C", otherwise we return the cat that is closer.
def catAndMouse(x, y, z): if abs(z - y) == abs(z - x): return "Mouse C" return "Cat A" if abs(z - x) < abs(z - y) else "Cat B"
Seems like cookies are disabled on this browser, please enable them to open this website
Cats and a Mouse
You are viewing a single comment's thread. Return to all comments →
Here is my quick and easy Python solution. If the cats are the same distance away, we return "Mouse C", otherwise we return the cat that is closer.