this is the solution to the cats and mouse problem in hackerrank. https://www.hackerrank.com/challenges/cats-and-a-mouse/problem?isFullScreen=true
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function catAndMouse(x, y, z) { | |
const diffA = Math.abs(z-x); | |
const diffB = Math.abs(z-y); | |
if(diffA === diffB) return "Mouse C"; | |
return diffA < diffB ? "Cat A" : "Cat B"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment