Skip to content

Instantly share code, notes, and snippets.

@pepet96
Created December 2, 2013 00:59
Show Gist options
  • Save pepet96/7743231 to your computer and use it in GitHub Desktop.
Save pepet96/7743231 to your computer and use it in GitHub Desktop.
Transversing Grid
mport java.util.Scanner;
public class TraversingGrid {
public static void main (String [] args) {
Scanner input = new Scanner(System.in);
String[] output = new String[input.nextInt()];
for (int i = 0; i < output.length; i++) {
int n = input.nextInt();
int m = input.nextInt();
if (n > m) {
if (m % 2 == 0)
output[i] = "U";
else
output[i] = "D";
}
else {
if (n % 2 == 0)
output[i] = "L";
else
output[i] = "R";
}
}
for (int i = 0; i < output.length; i++)
System.out.println(output[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment