Created
November 2, 2015 23:23
-
-
Save erdem/69a172625cf6ddbb6b4f to your computer and use it in GitHub Desktop.
CodinGame: The Descent
This file contains 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
/** | |
* Auto-generated code below aims at helping you parse | |
* the standard input according to the problem statement. | |
**/ | |
// game loop | |
while (true) { | |
var inputs = readline().split(' '); | |
var spaceX = parseInt(inputs[0]); | |
var spaceY = parseInt(inputs[1]); | |
var maxHeight = 0 | |
var targetMountain; | |
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 > maxHeight){ | |
maxHeight = mountainH | |
targetMountain = i | |
} | |
} | |
if (spaceX==targetMountain){ | |
print('FIRE') | |
}else{ | |
print('HOLD') | |
} | |
// either: FIRE (ship is firing its phase cannons) or HOLD (ship is not firing). | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment