Advertisement
Guest User

Layton163.java

a guest
Apr 5th, 2020
680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. public class Layton {
  2.     public static String[] validAEndPoints = new String[] { "A", "-1", "B", "-2", "C", "-3", "-4", "-5", "-6", "D", "-7", "-8", "E",
  3.             "-9", "-10", "-11", "F" };
  4.     public static String[] validFEndPoints = new String[] { "A", "-12", "B", "-13", "C", "D", "E", "-14", "-15", "-16", "F" };
  5.     public static void main(String[] args) {
  6.         int startA = 0;
  7.         int endA = 16;
  8.         int positionA = 0;
  9.         boolean reverseA = false;
  10.         int startF = 10;
  11.         int endF = 0;
  12.         int positionF = 10;
  13.         boolean reverseF = true;
  14.         Layton layton = new Layton();
  15.         while (!layton.checkIfInteresctingPoints(positionA, positionF)) {
  16.             if (positionA <= endA && !reverseA) {
  17.                 positionA++;
  18.             }
  19.             if (positionA > startA && reverseA) {
  20.                 positionA--;
  21.             }
  22.             if (positionF >= endF && reverseF) {
  23.                 positionF--;
  24.             }
  25.             if (positionF < startF && !reverseF) {
  26.                 positionF++;
  27.             }
  28.             if (positionA == endA || positionA == startA) {
  29.                 reverseA = !reverseA;
  30.             }
  31.             if (positionF == startF || positionF == endF) {
  32.                 reverseF = !reverseF;
  33.             }
  34.         }
  35.         System.out.println(validAEndPoints[positionA]);
  36.     }
  37.  
  38.     public boolean checkIfInteresctingPoints(int A, int F) {
  39.         if (validAEndPoints[A] == validFEndPoints[F]) {
  40.             return true;
  41.         }
  42.         return false;
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement