Skip to content

Instantly share code, notes, and snippets.

@deadkff01
Created December 12, 2016 16:17
Show Gist options
  • Save deadkff01/5350a2dbfda21b4d85dd0df9060bb758 to your computer and use it in GitHub Desktop.
Save deadkff01/5350a2dbfda21b4d85dd0df9060bb758 to your computer and use it in GitHub Desktop.
The Descent - Solution
// game loop
while (true) {
var largestMontain = 0;
var indexToShot = 0;
for (var i = 0; i < 8; i++) {
var mountainH = parseInt(readline()); // represents the height of one mountain.
if(largestMontain < mountainH) {
largestMontain = mountainH;
indexToShot = i;
}
}
// Write an action using print()
// To debug: printErr('Debug messages...');
print(indexToShot); // The index of the mountain to fire on.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment