Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Layton {
- public static String[] validAEndPoints = new String[] { "A", "-1", "B", "-2", "C", "-3", "-4", "-5", "-6", "D", "-7", "-8", "E",
- "-9", "-10", "-11", "F" };
- public static String[] validFEndPoints = new String[] { "A", "-12", "B", "-13", "C", "D", "E", "-14", "-15", "-16", "F" };
- public static void main(String[] args) {
- int startA = 0;
- int endA = 16;
- int positionA = 0;
- boolean reverseA = false;
- int startF = 10;
- int endF = 0;
- int positionF = 10;
- boolean reverseF = true;
- Layton layton = new Layton();
- while (!layton.checkIfInteresctingPoints(positionA, positionF)) {
- if (positionA <= endA && !reverseA) {
- positionA++;
- }
- if (positionA > startA && reverseA) {
- positionA--;
- }
- if (positionF >= endF && reverseF) {
- positionF--;
- }
- if (positionF < startF && !reverseF) {
- positionF++;
- }
- if (positionA == endA || positionA == startA) {
- reverseA = !reverseA;
- }
- if (positionF == startF || positionF == endF) {
- reverseF = !reverseF;
- }
- }
- System.out.println(validAEndPoints[positionA]);
- }
- public boolean checkIfInteresctingPoints(int A, int F) {
- if (validAEndPoints[A] == validFEndPoints[F]) {
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement