Advertisement
andradedearthur

Power of Thor

Apr 8th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. /* The Power of Thor - by Arthur D. de Andrade - Codingame */
  2.  
  3. import java.util.*;
  4. import java.io.*;
  5. import java.math.*;
  6.  
  7. class Player {
  8.  
  9.     public static void main(String args[]) {
  10.         Scanner in = new Scanner(System.in);
  11.        
  12.         int LX = in.nextInt();
  13.         int LY = in.nextInt();
  14.        
  15.         int TX = in.nextInt();
  16.         int TY = in.nextInt();
  17.        
  18.         // game loop
  19.         while (true) {
  20.             int E = in.nextInt(); // Quantidades de movimentos permitidos
  21.             String mov = ""; // Var usada p/ passar as coordenadas
  22.            
  23.             if ((TY < LY) && (TY < 17)) {
  24.                 mov = "S";
  25.                 TY++;
  26.             }
  27.             else if ((TY > LY) && (TY > 0)) {
  28.                 mov = "N";
  29.                 TY--;
  30.             }
  31.             System.err.println("TY: " + TY);
  32.            
  33.             if ((TX < LX) && (TX < 39)){
  34.                 mov += "E";
  35.                 TX++;
  36.             }
  37.             else if ((TX > LX) && (TX > 0)) {
  38.                 mov += "W";
  39.                 TX--;
  40.             }
  41.             System.err.println("TX: " + TX);
  42.    
  43.             System.out.println(mov); // A single line providing the move to be made: N NE E SE S SW W or NW
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement