You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution, you can watch the explanation here : https://youtu.be/vbV5-DqJU74
string catAndMouse(int x, int y, int z) { int a = abs(x-z), b = abs(y-z); if(a==b) return "Mouse C"; if(a < b) return "Cat A"; return "Cat B"; }
Short version
string catAndMouse(int x, int y, int z) { int a = abs(x-z), b = abs(y-z); return (a > b) ? "Cat B" : (a < b) ? "Cat A" : "Mouse C"; }
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 c++ solution, you can watch the explanation here : https://youtu.be/vbV5-DqJU74
Short version