• + 0 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"