Advertisement
abhisekp

CodinGame - Power of Thor

Jan 31st, 2015
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1.         // game loop
  2.         while (true) {
  3.             int E = in.nextInt(); // The level of Thor's remaining energy, representing the number of moves he can still make.
  4.  
  5.             String direction = "";
  6.             if(LY > TyPos && TyPos < 18) {
  7.                 direction += "S";
  8.                 TyPos++;
  9.                 System.err.println("Thor Pos = (" + TxPos + "," + TyPos + ")");
  10.             } else if(LY < TyPos && TyPos > 0) {
  11.                 direction += "N";
  12.                 TyPos--;
  13.                 System.err.println("Thor Pos = (" + TxPos + "," + TyPos + ")");
  14.             }
  15.             if(LX > TxPos && TxPos < 40) {
  16.                 direction += "E";
  17.                 TxPos++;
  18.                 System.err.println("Thor Pos = (" + TxPos + "," + TyPos + ")");
  19.             } else if(LX < TxPos && TxPos > 0) {
  20.                 direction += "W";
  21.                 TxPos--;
  22.                 System.err.println("Thor Pos = (" + TxPos + "," + TyPos + ")");
  23.             }
  24.  
  25.             System.out.println(direction); // A single line providing the move to be made: N NE E SE S SW W or NW
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement