Created
May 26, 2022 07:24
-
-
Save rachidelaid/73dad78e9e78bbca4fe7daeb37b5e366 to your computer and use it in GitHub Desktop.
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 hidden or 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