• + 1 comment

    JavaScript solution:

    /**
     * x - cat a
     * y - cat b
     * z - mouse
     */
    function catAndMouse(x, y, z) {
        const catA = Math.abs(x - z);
        const catB = Math.abs(y - z);
        
        console.log(catA, catB);
        
        if (catA === catB) {
            return 'Mouse C';
        } else if (catA < catB) {
            return 'Cat A';
        } else if (catA > catB) {
            return 'Cat B';
        }
    }