We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6e2950a commit d3d69feCopy full SHA for d3d69fe
1 file changed
Cats and a Mouse/main.js
@@ -0,0 +1,12 @@
1
+#!/usr/bin/env node
2
+
3
+// Problem Description at -> https://www.hackerrank.com/challenges/cats-and-a-mouse/problem
4
5
+function catAndMouse(x, y, z) {
6
+ if (Math.abs(z - x) == Math.abs(z - y)) return 'Mouse C';
7
+ if (Math.abs(z - x) < Math.abs(z - y)) return 'Cat A';
8
+ return 'Cat B';
9
+}
10
11
+// console.log(catAndMouse(1, 2, 3)); // Cat B
12
+console.log(catAndMouse(1, 3, 2)); // Mouse C
0 commit comments