Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package rascunhos_etc;
- import java.util.*;
- public class Testandooooooooo {
- public static void main(String[] projeto) {
- Scanner digitação = new Scanner(System.in);
- long tempoTotal = 0;
- System.out.println("Qual puzzle você deseja treinar: skewb, 2x2, 3x3 ou megaminx?");
- String resposta = digitação.nextLine();
- for (int solvesCounter = 1; solvesCounter < 13; solvesCounter++) {
- if (resposta.contains("cubo")) {
- Random r = new Random();
- //Array com todos os movimentos do cubo em seu sentido natural:
- String[] globalMoves = {"F", "B", "U", "D", "R", "L"};
- //Arrays auxiliares:
- String[] globalMovesMenosMoves1 = {"U", "D", "R", "L"};
- String[] globalMovesMenosMoves2 = {"B", "F", "L", "R"};
- String[] globalMovesMenosMoves3 = {"F", "B", "U", "D"};
- //Array do sentido a qual um movimento será atribuído:
- String[] sentido = {" ", "' ", "2 "};
- //Arrays classificados (sorted) dos movimentos baseados em oposição de faces:
- String[] moves1 = {"B", "F"};
- String[] moves2 = {"D", "U"};
- String[] moves3 = {"L", "R"};
- //Sorteio do sentido dos movimentos antecipadamente:
- String mm1 = sentido[r.nextInt(3)];
- String mm2 = sentido[r.nextInt(3)];
- String mm3 = sentido[r.nextInt(3)];
- String mm4 = sentido[r.nextInt(3)];
- String mm5 = sentido[r.nextInt(3)];
- String mm6 = sentido[r.nextInt(3)];
- String mm7 = sentido[r.nextInt(3)];
- String mm8 = sentido[r.nextInt(3)];
- String mm9 = sentido[r.nextInt(3)];
- String mm10 = sentido[r.nextInt(3)];
- String mm11 = sentido[r.nextInt(3)];
- String mm12 = sentido[r.nextInt(3)];
- String mm13 = sentido[r.nextInt(3)];
- String mm14 = sentido[r.nextInt(3)];
- String mm15 = sentido[r.nextInt(3)];
- String mm16 = sentido[r.nextInt(3)];
- String mm17 = sentido[r.nextInt(3)];
- String mm18 = sentido[r.nextInt(3)];
- String mm19 = sentido[r.nextInt(3)];
- String mm20 = sentido[r.nextInt(3)];
- String mm21 = sentido[r.nextInt(3)];
- String mm22 = sentido[r.nextInt(3)];
- String mm23 = sentido[r.nextInt(3)];
- String mm24 = sentido[r.nextInt(3)];
- String mm25 = sentido[r.nextInt(3)];
- //Sorteio dos movimentos baseado em todas as restrições cabíveis:
- String m1 = globalMoves[r.nextInt(6)];
- String m2 = "";
- do {
- m2 = globalMoves[r.nextInt(6)];
- } while (m2 == m1);
- //-------------------------------------------------------------------------//
- boolean opostosOk = false;
- int testeA = Arrays.binarySearch(moves1, m1);
- int testeB = Arrays.binarySearch(moves1, m2);
- int testeC = Arrays.binarySearch(moves2, m1);
- int testeD = Arrays.binarySearch(moves2, m2);
- int testeE = Arrays.binarySearch(moves3, m1);
- int testeF = Arrays.binarySearch(moves3, m2);
- if ((testeA >= 0 && testeB >= 0) || (testeC >= 0 && testeD >= 0) || (testeE >= 0 && testeF >= 0)) {
- opostosOk = true;
- }
- String m3 = "";
- if (opostosOk) {
- int buscaM11 = Arrays.binarySearch(moves1, m1);
- int buscaM12 = Arrays.binarySearch(moves2, m1);
- int buscaM13 = Arrays.binarySearch(moves3, m1);
- if (buscaM11 >= 0) {
- m3 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m3 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m3 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m3 = globalMoves[r.nextInt(6)];
- } while (m3 == m2);
- }
- //-------------------------------------------------------------------------//
- boolean opostosOk2 = false;
- int testeA2 = Arrays.binarySearch(moves1, m2);
- int testeB2 = Arrays.binarySearch(moves1, m3);
- int testeC2 = Arrays.binarySearch(moves2, m2);
- int testeD2 = Arrays.binarySearch(moves2, m3);
- int testeE2 = Arrays.binarySearch(moves3, m2);
- int testeF2 = Arrays.binarySearch(moves3, m3);
- if ((testeA2 >= 0 && testeB2 >= 0) || (testeC2 >= 0 && testeD2 >= 0) || (testeE2 >= 0 && testeF2 >= 0)) {
- opostosOk2 = true;
- }
- String m4 = "";
- if (opostosOk2) {
- int buscaM11 = Arrays.binarySearch(moves1, m2);
- int buscaM12 = Arrays.binarySearch(moves2, m2);
- int buscaM13 = Arrays.binarySearch(moves3, m2);
- if (buscaM11 >= 0) {
- m4 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m4 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m4 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m4 = globalMoves[r.nextInt(6)];
- } while (m4 == m3);
- }
- //---------------------------------------------------------------------//
- boolean opostosOk3 = false;
- int testeA3 = Arrays.binarySearch(moves1, m3);
- int testeB3 = Arrays.binarySearch(moves1, m4);
- int testeC3 = Arrays.binarySearch(moves2, m3);
- int testeD3 = Arrays.binarySearch(moves2, m4);
- int testeE3 = Arrays.binarySearch(moves3, m3);
- int testeF3 = Arrays.binarySearch(moves3, m4);
- if ((testeA3 >= 0 && testeB3 >= 0) || (testeC3 >= 0 && testeD3 >= 0) || (testeE3 >= 0 && testeF3 >= 0)) {
- opostosOk3 = true;
- }
- String m5 = "";
- if (opostosOk3) {
- int buscaM11 = Arrays.binarySearch(moves1, m3);
- int buscaM12 = Arrays.binarySearch(moves2, m3);
- int buscaM13 = Arrays.binarySearch(moves3, m3);
- if (buscaM11 >= 0) {
- m5 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m5 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m5 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m5 = globalMoves[r.nextInt(6)];
- } while (m5 == m4);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk4 = false;
- int testeA4 = Arrays.binarySearch(moves1, m4);
- int testeB4 = Arrays.binarySearch(moves1, m5);
- int testeC4 = Arrays.binarySearch(moves2, m4);
- int testeD4 = Arrays.binarySearch(moves2, m5);
- int testeE4 = Arrays.binarySearch(moves3, m4);
- int testeF4 = Arrays.binarySearch(moves3, m5);
- if ((testeA4 >= 0 && testeB4 >= 0) || (testeC4 >= 0 && testeD4 >= 0) || (testeE4 >= 0 && testeF4 >= 0)) {
- opostosOk4 = true;
- }
- String m6 = "";
- if (opostosOk4) {
- int buscaM11 = Arrays.binarySearch(moves1, m4);
- int buscaM12 = Arrays.binarySearch(moves2, m4);
- int buscaM13 = Arrays.binarySearch(moves3, m4);
- if (buscaM11 >= 0) {
- m6 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m6 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m6 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m6 = globalMoves[r.nextInt(6)];
- } while (m6 == m5);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk5 = false;
- int testeA5 = Arrays.binarySearch(moves1, m5);
- int testeB5 = Arrays.binarySearch(moves1, m6);
- int testeC5 = Arrays.binarySearch(moves2, m5);
- int testeD5 = Arrays.binarySearch(moves2, m6);
- int testeE5 = Arrays.binarySearch(moves3, m4);
- int testeF5 = Arrays.binarySearch(moves3, m5);
- if ((testeA5 >= 0 && testeB5 >= 0) || (testeC5 >= 0 && testeD5 >= 0) || (testeE5 >= 0 && testeF5 >= 0)) {
- opostosOk5 = true;
- }
- String m7 = "";
- if (opostosOk5) {
- int buscaM11 = Arrays.binarySearch(moves1, m5);
- int buscaM12 = Arrays.binarySearch(moves2, m5);
- int buscaM13 = Arrays.binarySearch(moves3, m5);
- if (buscaM11 >= 0) {
- m7 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m7 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m7 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m7 = globalMoves[r.nextInt(6)];
- } while (m7 == m6);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk6 = false;
- int testeA6 = Arrays.binarySearch(moves1, m6);
- int testeB6 = Arrays.binarySearch(moves1, m7);
- int testeC6 = Arrays.binarySearch(moves2, m6);
- int testeD6 = Arrays.binarySearch(moves2, m7);
- int testeE6 = Arrays.binarySearch(moves3, m6);
- int testeF6 = Arrays.binarySearch(moves3, m7);
- if ((testeA6 >= 0 && testeB6 >= 0) || (testeC6 >= 0 && testeD6 >= 0) || (testeE6 >= 0 && testeF6 >= 0)) {
- opostosOk6 = true;
- }
- String m8 = "";
- if (opostosOk6) {
- int buscaM11 = Arrays.binarySearch(moves1, m6);
- int buscaM12 = Arrays.binarySearch(moves2, m6);
- int buscaM13 = Arrays.binarySearch(moves3, m6);
- if (buscaM11 >= 0) {
- m8 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m8 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m8 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m8 = globalMoves[r.nextInt(6)];
- } while (m8 == m7);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk7 = false;
- int testeA7 = Arrays.binarySearch(moves1, m7);
- int testeB7 = Arrays.binarySearch(moves1, m8);
- int testeC7 = Arrays.binarySearch(moves2, m7);
- int testeD7 = Arrays.binarySearch(moves2, m8);
- int testeE7 = Arrays.binarySearch(moves3, m7);
- int testeF7 = Arrays.binarySearch(moves3, m8);
- if ((testeA7 >= 0 && testeB7 >= 0) || (testeC7 >= 0 && testeD7 >= 0) || (testeE7 >= 0 && testeF7 >= 0)) {
- opostosOk7 = true;
- }
- String m9 = "";
- if (opostosOk7) {
- int buscaM11 = Arrays.binarySearch(moves1, m7);
- int buscaM12 = Arrays.binarySearch(moves2, m7);
- int buscaM13 = Arrays.binarySearch(moves3, m7);
- if (buscaM11 >= 0) {
- m9 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m9 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m9 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m9 = globalMoves[r.nextInt(6)];
- } while (m9 == m8);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk8 = false;
- int testeA8 = Arrays.binarySearch(moves1, m8);
- int testeB8 = Arrays.binarySearch(moves1, m9);
- int testeC8 = Arrays.binarySearch(moves2, m8);
- int testeD8 = Arrays.binarySearch(moves2, m9);
- int testeE8 = Arrays.binarySearch(moves3, m8);
- int testeF8 = Arrays.binarySearch(moves3, m9);
- if ((testeA8 >= 0 && testeB8 >= 0) || (testeC8 >= 0 && testeD8 >= 0) || (testeE8 >= 0 && testeF8 >= 0)) {
- opostosOk8 = true;
- }
- String m10 = "";
- if (opostosOk8) {
- int buscaM11 = Arrays.binarySearch(moves1, m8);
- int buscaM12 = Arrays.binarySearch(moves2, m8);
- int buscaM13 = Arrays.binarySearch(moves3, m8);
- if (buscaM11 >= 0) {
- m10 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m10 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m10 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m10 = globalMoves[r.nextInt(6)];
- } while (m10 == m9);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk9 = false;
- int testeA9 = Arrays.binarySearch(moves1, m9);
- int testeB9 = Arrays.binarySearch(moves1, m10);
- int testeC9 = Arrays.binarySearch(moves2, m9);
- int testeD9 = Arrays.binarySearch(moves2, m10);
- int testeE9 = Arrays.binarySearch(moves3, m9);
- int testeF9 = Arrays.binarySearch(moves3, m10);
- if ((testeA9 >= 0 && testeB9 >= 0) || (testeC9 >= 0 && testeD9 >= 0) || (testeE9 >= 0 && testeF9 >= 0)) {
- opostosOk9 = true;
- }
- String m11 = "";
- if (opostosOk9) {
- int buscaM11 = Arrays.binarySearch(moves1, m9);
- int buscaM12 = Arrays.binarySearch(moves2, m9);
- int buscaM13 = Arrays.binarySearch(moves3, m9);
- if (buscaM11 >= 0) {
- m11 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m11 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m11 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m11 = globalMoves[r.nextInt(6)];
- } while (m11 == m10);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk10 = false;
- int testeA10 = Arrays.binarySearch(moves1, m10);
- int testeB10 = Arrays.binarySearch(moves1, m11);
- int testeC10 = Arrays.binarySearch(moves2, m10);
- int testeD10 = Arrays.binarySearch(moves2, m11);
- int testeE10 = Arrays.binarySearch(moves3, m10);
- int testeF10 = Arrays.binarySearch(moves3, m11);
- if ((testeA10 >= 0 && testeB10 >= 0) || (testeC10 >= 0 && testeD10 >= 0) || (testeE10 >= 0 && testeF10 >= 0)) {
- opostosOk10 = true;
- }
- String m12 = "";
- if (opostosOk10) {
- int buscaM11 = Arrays.binarySearch(moves1, m10);
- int buscaM12 = Arrays.binarySearch(moves2, m10);
- int buscaM13 = Arrays.binarySearch(moves3, m10);
- if (buscaM11 >= 0) {
- m12 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m12 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m12 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m12 = globalMoves[r.nextInt(6)];
- } while (m12 == m11);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk11 = false;
- int testeA11 = Arrays.binarySearch(moves1, m11);
- int testeB11 = Arrays.binarySearch(moves1, m12);
- int testeC11 = Arrays.binarySearch(moves2, m11);
- int testeD11 = Arrays.binarySearch(moves2, m12);
- int testeE11 = Arrays.binarySearch(moves3, m11);
- int testeF11 = Arrays.binarySearch(moves3, m12);
- if ((testeA11 >= 0 && testeB11 >= 0) || (testeC11 >= 0 && testeD11 >= 0) || (testeE11 >= 0 && testeF11 >= 0)) {
- opostosOk11 = true;
- }
- String m13 = "";
- if (opostosOk11) {
- int buscaM11 = Arrays.binarySearch(moves1, m11);
- int buscaM12 = Arrays.binarySearch(moves2, m11);
- int buscaM13 = Arrays.binarySearch(moves3, m11);
- if (buscaM11 >= 0) {
- m13 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m13 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m13 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m13 = globalMoves[r.nextInt(6)];
- } while (m13 == m12);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk12 = false;
- int testeA12 = Arrays.binarySearch(moves1, m12);
- int testeB12 = Arrays.binarySearch(moves1, m13);
- int testeC12 = Arrays.binarySearch(moves2, m12);
- int testeD12 = Arrays.binarySearch(moves2, m13);
- int testeE12 = Arrays.binarySearch(moves3, m12);
- int testeF12 = Arrays.binarySearch(moves3, m13);
- if ((testeA12 >= 0 && testeB12 >= 0) || (testeC12 >= 0 && testeD12 >= 0) || (testeE12 >= 0 && testeF12 >= 0)) {
- opostosOk12 = true;
- }
- String m14 = "";
- if (opostosOk12) {
- int buscaM11 = Arrays.binarySearch(moves1, m12);
- int buscaM12 = Arrays.binarySearch(moves2, m12);
- int buscaM13 = Arrays.binarySearch(moves3, m12);
- if (buscaM11 >= 0) {
- m14 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m14 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m14 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m14 = globalMoves[r.nextInt(6)];
- } while (m14 == m13);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk13 = false;
- int testeA13 = Arrays.binarySearch(moves1, m13);
- int testeB13 = Arrays.binarySearch(moves1, m14);
- int testeC13 = Arrays.binarySearch(moves2, m13);
- int testeD13 = Arrays.binarySearch(moves2, m14);
- int testeE13 = Arrays.binarySearch(moves3, m13);
- int testeF13 = Arrays.binarySearch(moves3, m14);
- if ((testeA13 >= 0 && testeB13 >= 0) || (testeC13 >= 0 && testeD13 >= 0) || (testeE13 >= 0 && testeF13 >= 0)) {
- opostosOk13 = true;
- }
- String m15 = "";
- if (opostosOk13) {
- int buscaM11 = Arrays.binarySearch(moves1, m13);
- int buscaM12 = Arrays.binarySearch(moves2, m13);
- int buscaM13 = Arrays.binarySearch(moves3, m13);
- if (buscaM11 >= 0) {
- m15 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m15 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m15 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m15 = globalMoves[r.nextInt(6)];
- } while (m15 == m14);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk14 = false;
- int testeA14 = Arrays.binarySearch(moves1, m14);
- int testeB14 = Arrays.binarySearch(moves1, m15);
- int testeC14 = Arrays.binarySearch(moves2, m14);
- int testeD14 = Arrays.binarySearch(moves2, m15);
- int testeE14 = Arrays.binarySearch(moves3, m14);
- int testeF14 = Arrays.binarySearch(moves3, m15);
- if ((testeA14 >= 0 && testeB14 >= 0) || (testeC14 >= 0 && testeD14 >= 0) || (testeE14 >= 0 && testeF14 >= 0)) {
- opostosOk14 = true;
- }
- String m16 = "";
- if (opostosOk14) {
- int buscaM11 = Arrays.binarySearch(moves1, m14);
- int buscaM12 = Arrays.binarySearch(moves2, m14);
- int buscaM13 = Arrays.binarySearch(moves3, m14);
- if (buscaM11 >= 0) {
- m16 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m16 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m16 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m16 = globalMoves[r.nextInt(6)];
- } while (m16 == m15);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk15 = false;
- int testeA15 = Arrays.binarySearch(moves1, m15);
- int testeB15 = Arrays.binarySearch(moves1, m16);
- int testeC15 = Arrays.binarySearch(moves2, m15);
- int testeD15 = Arrays.binarySearch(moves2, m16);
- int testeE15 = Arrays.binarySearch(moves3, m15);
- int testeF15 = Arrays.binarySearch(moves3, m16);
- if ((testeA15 >= 0 && testeB15 >= 0) || (testeC15 >= 0 && testeD15 >= 0) || (testeE15 >= 0 && testeF15 >= 0)) {
- opostosOk15 = true;
- }
- String m17 = "";
- if (opostosOk15) {
- int buscaM11 = Arrays.binarySearch(moves1, m15);
- int buscaM12 = Arrays.binarySearch(moves2, m15);
- int buscaM13 = Arrays.binarySearch(moves3, m15);
- if (buscaM11 >= 0) {
- m17 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m17 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m17 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m17 = globalMoves[r.nextInt(6)];
- } while (m17 == m16);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk16 = false;
- int testeA16 = Arrays.binarySearch(moves1, m16);
- int testeB16 = Arrays.binarySearch(moves1, m17);
- int testeC16 = Arrays.binarySearch(moves2, m16);
- int testeD16 = Arrays.binarySearch(moves2, m17);
- int testeE16 = Arrays.binarySearch(moves3, m16);
- int testeF16 = Arrays.binarySearch(moves3, m17);
- if ((testeA16 >= 0 && testeB16 >= 0) || (testeC16 >= 0 && testeD16 >= 0) || (testeE16 >= 0 && testeF16 >= 0)) {
- opostosOk16 = true;
- }
- String m18 = "";
- if (opostosOk16) {
- int buscaM11 = Arrays.binarySearch(moves1, m16);
- int buscaM12 = Arrays.binarySearch(moves2, m16);
- int buscaM13 = Arrays.binarySearch(moves3, m16);
- if (buscaM11 >= 0) {
- m18 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m18 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m18 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m18 = globalMoves[r.nextInt(6)];
- } while (m18 == m17);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk17 = false;
- int testeA17 = Arrays.binarySearch(moves1, m17);
- int testeB17 = Arrays.binarySearch(moves1, m18);
- int testeC17 = Arrays.binarySearch(moves2, m17);
- int testeD17 = Arrays.binarySearch(moves2, m18);
- int testeE17 = Arrays.binarySearch(moves3, m17);
- int testeF17 = Arrays.binarySearch(moves3, m18);
- if ((testeA17 >= 0 && testeB17 >= 0) || (testeC17 >= 0 && testeD17 >= 0) || (testeE17 >= 0 && testeF17 >= 0)) {
- opostosOk17 = true;
- }
- String m19 = "";
- if (opostosOk17) {
- int buscaM11 = Arrays.binarySearch(moves1, m17);
- int buscaM12 = Arrays.binarySearch(moves2, m17);
- int buscaM13 = Arrays.binarySearch(moves3, m17);
- if (buscaM11 >= 0) {
- m19 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m19 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m19 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m19 = globalMoves[r.nextInt(6)];
- } while (m19 == m18);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk18 = false;
- int testeA18 = Arrays.binarySearch(moves1, m18);
- int testeB18 = Arrays.binarySearch(moves1, m19);
- int testeC18 = Arrays.binarySearch(moves2, m18);
- int testeD18 = Arrays.binarySearch(moves2, m19);
- int testeE18 = Arrays.binarySearch(moves3, m18);
- int testeF18 = Arrays.binarySearch(moves3, m19);
- if ((testeA18 >= 0 && testeB18 >= 0) || (testeC18 >= 0 && testeD18 >= 0) || (testeE18 >= 0 && testeF18 >= 0)) {
- opostosOk18 = true;
- }
- String m20 = "";
- if (opostosOk18) {
- int buscaM11 = Arrays.binarySearch(moves1, m18);
- int buscaM12 = Arrays.binarySearch(moves2, m18);
- int buscaM13 = Arrays.binarySearch(moves3, m18);
- if (buscaM11 >= 0) {
- m20 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m20 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m20 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m20 = globalMoves[r.nextInt(6)];
- } while (m20 == m19);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk19 = false;
- int testeA19 = Arrays.binarySearch(moves1, m19);
- int testeB19 = Arrays.binarySearch(moves1, m20);
- int testeC19 = Arrays.binarySearch(moves2, m19);
- int testeD19 = Arrays.binarySearch(moves2, m20);
- int testeE19 = Arrays.binarySearch(moves3, m19);
- int testeF19 = Arrays.binarySearch(moves3, m20);
- if ((testeA19 >= 0 && testeB19 >= 0) || (testeC19 >= 0 && testeD19 >= 0) || (testeE19 >= 0 && testeF19 >= 0)) {
- opostosOk19 = true;
- }
- String m21 = "";
- if (opostosOk19) {
- int buscaM11 = Arrays.binarySearch(moves1, m19);
- int buscaM12 = Arrays.binarySearch(moves2, m19);
- int buscaM13 = Arrays.binarySearch(moves3, m19);
- if (buscaM11 >= 0) {
- m21 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m21 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m21 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m21 = globalMoves[r.nextInt(6)];
- } while (m21 == m20);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk20 = false;
- int testeA20 = Arrays.binarySearch(moves1, m20);
- int testeB20 = Arrays.binarySearch(moves1, m21);
- int testeC20 = Arrays.binarySearch(moves2, m20);
- int testeD20 = Arrays.binarySearch(moves2, m21);
- int testeE20 = Arrays.binarySearch(moves3, m20);
- int testeF20 = Arrays.binarySearch(moves3, m21);
- if ((testeA20 >= 0 && testeB20 >= 0) || (testeC20 >= 0 && testeD20 >= 0) || (testeE20 >= 0 && testeF20 >= 0)) {
- opostosOk20 = true;
- }
- String m22 = "";
- if (opostosOk20) {
- int buscaM11 = Arrays.binarySearch(moves1, m20);
- int buscaM12 = Arrays.binarySearch(moves2, m20);
- int buscaM13 = Arrays.binarySearch(moves3, m20);
- if (buscaM11 >= 0) {
- m22 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m22 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m22 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m22 = globalMoves[r.nextInt(6)];
- } while (m22 == m21);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk21 = false;
- int testeA21 = Arrays.binarySearch(moves1, m21);
- int testeB21 = Arrays.binarySearch(moves1, m22);
- int testeC21 = Arrays.binarySearch(moves2, m21);
- int testeD21 = Arrays.binarySearch(moves2, m22);
- int testeE21 = Arrays.binarySearch(moves3, m21);
- int testeF21 = Arrays.binarySearch(moves3, m22);
- if ((testeA21 >= 0 && testeB21 >= 0) || (testeC21 >= 0 && testeD21 >= 0) || (testeE21 >= 0 && testeF21 >= 0)) {
- opostosOk21 = true;
- }
- String m23 = "";
- if (opostosOk21) {
- int buscaM11 = Arrays.binarySearch(moves1, m21);
- int buscaM12 = Arrays.binarySearch(moves2, m21);
- int buscaM13 = Arrays.binarySearch(moves3, m21);
- if (buscaM11 >= 0) {
- m23 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m23 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m23 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m23 = globalMoves[r.nextInt(6)];
- } while (m23 == m22);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk22 = false;
- int testeA22 = Arrays.binarySearch(moves1, m22);
- int testeB22 = Arrays.binarySearch(moves1, m23);
- int testeC22 = Arrays.binarySearch(moves2, m22);
- int testeD22 = Arrays.binarySearch(moves2, m23);
- int testeE22 = Arrays.binarySearch(moves3, m22);
- int testeF22 = Arrays.binarySearch(moves3, m23);
- if ((testeA22 >= 0 && testeB22 >= 0) || (testeC22 >= 0 && testeD22 >= 0) || (testeE22 >= 0 && testeF22 >= 0)) {
- opostosOk22 = true;
- }
- String m24 = "";
- if (opostosOk22) {
- int buscaM11 = Arrays.binarySearch(moves1, m22);
- int buscaM12 = Arrays.binarySearch(moves2, m22);
- int buscaM13 = Arrays.binarySearch(moves3, m22);
- if (buscaM11 >= 0) {
- m24 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m24 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m24 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m24 = globalMoves[r.nextInt(6)];
- } while (m24 == m23);
- }
- //-------------------------------------------------------------------//
- boolean opostosOk23 = false;
- int testeA23 = Arrays.binarySearch(moves1, m23);
- int testeB23 = Arrays.binarySearch(moves1, m24);
- int testeC23 = Arrays.binarySearch(moves2, m23);
- int testeD23 = Arrays.binarySearch(moves2, m24);
- int testeE23 = Arrays.binarySearch(moves3, m23);
- int testeF23 = Arrays.binarySearch(moves3, m24);
- if ((testeA23 >= 0 && testeB23 >= 0) || (testeC23 >= 0 && testeD23 >= 0) || (testeE23 >= 0 && testeF23 >= 0)) {
- opostosOk23 = true;
- }
- String m25 = "";
- if (opostosOk23) {
- int buscaM11 = Arrays.binarySearch(moves1, m23);
- int buscaM12 = Arrays.binarySearch(moves2, m23);
- int buscaM13 = Arrays.binarySearch(moves3, m23);
- if (buscaM11 >= 0) {
- m25 = globalMovesMenosMoves1[r.nextInt(4)];
- } else if (buscaM12 >= 0) {
- m25 = globalMovesMenosMoves2[r.nextInt(4)];
- } else if (buscaM13 >= 0) {
- m25 = globalMovesMenosMoves3[r.nextInt(4)];
- }
- } else {
- do {
- m25 = globalMoves[r.nextInt(6)];
- } while (m25 == m24);
- }
- //-------------------------------------------------------------------//
- System.out.println(
- m1 + mm1 + m2 + mm2 + m3 + mm3 + m4 + mm4 + m5 +
- mm5 + m6 + mm6 + m7 + mm7 + m8 + mm8 + m9 + mm9 + m10
- + mm10 + m11 + mm11 + m12 + mm12 + m13 + mm13 + m14 +
- mm14 + m15 + mm15 + m16+ mm16 + m17 + mm17 + m18 +
- mm18 + m19 + mm19 + m20 + mm20 + m21 + mm21 + m22 +
- mm22 + m23 + mm23 + m24+ mm24 + m25 + mm25
- );
- System.out.println();
- System.out.println("------------------------------------------------------------------------");
- } else if (resposta.contains("2x2")) {
- String[] moves1 = {"F", "U", "R"};
- String[] moves2 = {" ", "' "};
- Random r = new Random();
- String s = "";
- String f = "";
- for (int i = 0; i < 8; i++) {
- do {
- f = moves1[r.nextInt(3)];
- } while (f == s);
- s = f;
- System.out.print(s);
- String u = moves2[r.nextInt(2)];
- System.out.print(u);
- }
- System.out.println();
- System.out.println("------------------------------------------------------------------------");
- } else if (resposta.contains("skewb")) {
- String[] moves1 = {"B", "U", "R", "L"};
- String[] moves3 = {" ", "' "};
- Random r = new Random();
- String s = "";
- String f = "";
- for (int i = 0; i < 12; i++) {
- do {
- f = moves1[r.nextInt(4)];
- } while (f == s);
- s = f;
- System.out.print(s);
- String u = moves3[r.nextInt(2)];
- System.out.print(u);
- }
- System.out.println();
- System.out.println("------------------------------------------------------------------------");
- } else {
- System.out.println("------------------------------------------------------------------------");
- String[] moves1 = {"++", "--"};
- String[] moves2 = {"U", "U'"};
- Random r = new Random();
- for (int j = 0; j < 8; j++) {
- for (int i = 0; i < 11; i++) {
- if (i % 2 == 0) {
- System.out.print("R");
- } else {
- System.out.print("D");
- }
- String s = moves1[r.nextInt(2)];
- System.out.print(s + " ");
- if (i == 10) {
- String u = moves2[r.nextInt(2)];
- System.out.println(u);
- }
- }
- }
- System.out.println("------------------------------------------------------------------------");
- }
- System.out.println("Está pronto? Pressione Enter para começar a contagem de tempo!");
- String estouPronto = digitação.nextLine();
- long começo = System.currentTimeMillis();
- System.out.println("TEMPO CORRENDO! MONTA SAPORRA AÊEEEE"); //gambiarra para manter o programa em execução durante a solve;
- String prolongamentoDeExecução = digitação.nextLine(); //apenas para que usuário dê Enter e o programa continue para a próxima etapa;
- long segundos = (System.currentTimeMillis() - começo) / 1000;
- // long centesimoFinal = (System.currentTimeMillis() -(System.currentTimeMillis() - começo) / 1000) / 100;
- tempoTotal = tempoTotal + segundos;
- long minutoFinal = segundos / 60;
- segundos = segundos % 60;
- //System.out.println("Resolveu em: " + segundoFinal + "." + centesimoFinal + " segundos!");
- if (segundos == 1) {
- System.out.println("Resolveu em: 0" + segundos);
- } else if (segundos < 10) {
- System.out.println("Resolveu em: " + minutoFinal + ": 0" + segundos);
- } else {
- System.out.println("Resolveu em: " + minutoFinal + ": " + segundos);
- }
- System.out.println("------------------------------------------------------------------------");
- double media = tempoTotal / solvesCounter;
- double mediaMinuto = media / 60;
- double mediaSegundo = media % 60;
- int minuto = (int) mediaMinuto;
- int segundo = (int) mediaSegundo;
- if (mediaSegundo == 1) {
- System.out.println("Média: 0" + mediaSegundo);
- } else if (mediaSegundo < 10) {
- System.out.println("Sua média: " + minuto + ": 0" + segundo);
- System.out.println("------------------------------------------------------------------------");
- } else {
- System.out.println("Sua média: " + minuto + ": " + segundo);
- System.out.println("------------------------------------------------------------------------");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement