Skip to content

Instantly share code, notes, and snippets.

@remibantos
Last active January 30, 2016 15:40
Show Gist options
  • Save remibantos/58f502e30279b63fb878 to your computer and use it in GitHub Desktop.
Save remibantos/58f502e30279b63fb878 to your computer and use it in GitHub Desktop.
codingame.com - The descent
package org.rembx.jeeshop.order;
import java.util.Scanner;
class Player {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int maxMountainH = 0;
int maxMountainX = 0;
// game loop
while (true) {
int spaceX = in.nextInt();
int spaceY = in.nextInt();
for (int i = 0; i < 8; i++) {
int mountainH = in.nextInt(); // represents the height of one mountain, from 9 to 0. Mountain heights are provided from left to right.
if (maxMountainH < mountainH) {
maxMountainX = i;
maxMountainH = mountainH;
}
}
System.err.println(spaceY + "," + maxMountainH + ":" + maxMountainX);
if (spaceX == maxMountainX) {
System.out.println("FIRE");
maxMountainH = 0;
maxMountainX = 0;
} else {
System.out.println("HOLD");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment