Last active
January 30, 2016 15:40
-
-
Save remibantos/58f502e30279b63fb878 to your computer and use it in GitHub Desktop.
codingame.com - 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
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