Created
October 26, 2014 17:44
-
-
Save bkopanja/8d0b732928a87bed05ba to your computer and use it in GitHub Desktop.
Codingame - Power of Thor
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
import java.util.*; | |
import java.io.*; | |
import java.math.*; | |
/** | |
* Auto-generated code below aims at helping you parse | |
* the standard input according to the problem statement. | |
**/ | |
class Player { | |
public static void main(String args[]) | |
{ | |
Scanner in = new Scanner(System.in); | |
int LX = in.nextInt(); // the X position of the light of power | |
int LY = in.nextInt(); // the Y position of the light of power | |
int TX = in.nextInt(); // Thor's starting X position | |
int TY = in.nextInt(); // Thor's starting Y position | |
in.nextLine(); | |
// game loop | |
while (true) { | |
int E = in.nextInt(); // The level of Thor's remaining energy, representing the number of moves he can still make. | |
in.nextLine(); | |
String direction = ""; | |
if (TY < LY) { | |
TY++; | |
direction = "S"; | |
} else if (TY > LY) { | |
TY--; | |
direction = "N"; | |
} | |
if (TX < LX) { | |
TX++; | |
direction += "E"; | |
} else if (TX > LX) { | |
TX--; | |
direction += "W"; | |
} | |
System.out.println(direction); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment