-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy paththeDescent.js
More file actions
27 lines (22 loc) · 832 Bytes
/
theDescent.js
File metadata and controls
27 lines (22 loc) · 832 Bytes
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
// game loop
while (true) {
var inputs = readline().split(' ');
var spaceX = parseInt(inputs[0]);
var spaceY = parseInt(inputs[1]);
var fireOrHold = 'HOLD'
var highestMountain = -1;
var greatestHeight = -1;
for (var i = 0; i < 8; i++) {
var mountainH = parseInt(readline()); // represents the height of one mountain, from 9 to 0. Mountain heights are provided from left to right.
if (mountainH > greatestHeight) {
greatestHeight = mountainH;
highestMountain = i;
}
}
if (highestMountain === spaceX) {
fireOrHold = 'FIRE';
}
// Write an action using print()
// To debug: printErr('Debug messages...');
print(fireOrHold); // either: FIRE (ship is firing its phase cannons) or HOLD (ship is not firing).
}