Skip to content

Instantly share code, notes, and snippets.

@erdem
Created November 2, 2015 23:23
Show Gist options
  • Save erdem/69a172625cf6ddbb6b4f to your computer and use it in GitHub Desktop.
Save erdem/69a172625cf6ddbb6b4f to your computer and use it in GitHub Desktop.
CodinGame: The Descent
/**
* 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