-
Notifications
You must be signed in to change notification settings - Fork 693
/
Solution.js
31 lines (25 loc) · 750 Bytes
/
Solution.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//Problem: https://www.hackerrank.com/challenges/game-of-stones-1
//JavaScript
/*
Initial Thoughts:
From the explanation given it can be determined that
if the number of stones mod 7 is equal to or less than 1
player two will win else player one will win.
Time Complexity: O(n) //Iterate over inputs
Space Complexity: O(1)
*/
function processData(input) {
for (let stones of input.split("\n").slice(1)) {
console.log((stones % 7 <= 1) ? "Second" : "First");
}
}
/////////////// ignore below this line \\\\\\\\\\\\\\\
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
_input += input;
});
process.stdin.on("end", function () {
processData(_input);
});