Advertisement
LucasSousa

Rubik's Cube Timer

Dec 2nd, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.40 KB | None | 0 0
  1. package rascunhos_etc;
  2.  
  3. import java.util.*;
  4.  
  5. public class Testandooooooooo {
  6.  
  7. public static void main(String[] projeto) {
  8.  
  9. Scanner digitação = new Scanner(System.in);
  10.  
  11. long tempoTotal = 0;
  12.  
  13. System.out.println("Qual puzzle você deseja treinar: skewb, 2x2, 3x3 ou megaminx?");
  14. String resposta = digitação.nextLine();
  15.  
  16. for (int solvesCounter = 1; solvesCounter < 13; solvesCounter++) {
  17.  
  18. if (resposta.contains("cubo")) {
  19. Random r = new Random();
  20.  
  21. //Array com todos os movimentos do cubo em seu sentido natural:
  22. String[] globalMoves = {"F", "B", "U", "D", "R", "L"};
  23.  
  24. //Arrays auxiliares:
  25. String[] globalMovesMenosMoves1 = {"U", "D", "R", "L"};
  26. String[] globalMovesMenosMoves2 = {"B", "F", "L", "R"};
  27. String[] globalMovesMenosMoves3 = {"F", "B", "U", "D"};
  28.  
  29. //Array do sentido a qual um movimento será atribuído:
  30. String[] sentido = {" ", "' ", "2 "};
  31.  
  32. //Arrays classificados (sorted) dos movimentos baseados em oposição de faces:
  33. String[] moves1 = {"B", "F"};
  34. String[] moves2 = {"D", "U"};
  35. String[] moves3 = {"L", "R"};
  36.  
  37. //Sorteio do sentido dos movimentos antecipadamente:
  38. String mm1 = sentido[r.nextInt(3)];
  39. String mm2 = sentido[r.nextInt(3)];
  40. String mm3 = sentido[r.nextInt(3)];
  41. String mm4 = sentido[r.nextInt(3)];
  42. String mm5 = sentido[r.nextInt(3)];
  43. String mm6 = sentido[r.nextInt(3)];
  44. String mm7 = sentido[r.nextInt(3)];
  45. String mm8 = sentido[r.nextInt(3)];
  46. String mm9 = sentido[r.nextInt(3)];
  47. String mm10 = sentido[r.nextInt(3)];
  48. String mm11 = sentido[r.nextInt(3)];
  49. String mm12 = sentido[r.nextInt(3)];
  50. String mm13 = sentido[r.nextInt(3)];
  51. String mm14 = sentido[r.nextInt(3)];
  52. String mm15 = sentido[r.nextInt(3)];
  53. String mm16 = sentido[r.nextInt(3)];
  54. String mm17 = sentido[r.nextInt(3)];
  55. String mm18 = sentido[r.nextInt(3)];
  56. String mm19 = sentido[r.nextInt(3)];
  57. String mm20 = sentido[r.nextInt(3)];
  58. String mm21 = sentido[r.nextInt(3)];
  59. String mm22 = sentido[r.nextInt(3)];
  60. String mm23 = sentido[r.nextInt(3)];
  61. String mm24 = sentido[r.nextInt(3)];
  62. String mm25 = sentido[r.nextInt(3)];
  63.  
  64. //Sorteio dos movimentos baseado em todas as restrições cabíveis:
  65. String m1 = globalMoves[r.nextInt(6)];
  66.  
  67. String m2 = "";
  68.  
  69. do {
  70.  
  71. m2 = globalMoves[r.nextInt(6)];
  72. } while (m2 == m1);
  73.  
  74. //-------------------------------------------------------------------------//
  75. boolean opostosOk = false;
  76.  
  77. int testeA = Arrays.binarySearch(moves1, m1);
  78. int testeB = Arrays.binarySearch(moves1, m2);
  79.  
  80. int testeC = Arrays.binarySearch(moves2, m1);
  81. int testeD = Arrays.binarySearch(moves2, m2);
  82.  
  83. int testeE = Arrays.binarySearch(moves3, m1);
  84. int testeF = Arrays.binarySearch(moves3, m2);
  85.  
  86. if ((testeA >= 0 && testeB >= 0) || (testeC >= 0 && testeD >= 0) || (testeE >= 0 && testeF >= 0)) {
  87.  
  88. opostosOk = true;
  89. }
  90.  
  91. String m3 = "";
  92.  
  93. if (opostosOk) {
  94.  
  95. int buscaM11 = Arrays.binarySearch(moves1, m1);
  96. int buscaM12 = Arrays.binarySearch(moves2, m1);
  97. int buscaM13 = Arrays.binarySearch(moves3, m1);
  98.  
  99. if (buscaM11 >= 0) {
  100.  
  101. m3 = globalMovesMenosMoves1[r.nextInt(4)];
  102.  
  103. } else if (buscaM12 >= 0) {
  104.  
  105. m3 = globalMovesMenosMoves2[r.nextInt(4)];
  106.  
  107. } else if (buscaM13 >= 0) {
  108.  
  109. m3 = globalMovesMenosMoves3[r.nextInt(4)];
  110.  
  111. }
  112.  
  113. } else {
  114.  
  115. do {
  116.  
  117. m3 = globalMoves[r.nextInt(6)];
  118.  
  119. } while (m3 == m2);
  120.  
  121. }
  122.  
  123. //-------------------------------------------------------------------------//
  124. boolean opostosOk2 = false;
  125.  
  126. int testeA2 = Arrays.binarySearch(moves1, m2);
  127. int testeB2 = Arrays.binarySearch(moves1, m3);
  128.  
  129. int testeC2 = Arrays.binarySearch(moves2, m2);
  130. int testeD2 = Arrays.binarySearch(moves2, m3);
  131.  
  132. int testeE2 = Arrays.binarySearch(moves3, m2);
  133. int testeF2 = Arrays.binarySearch(moves3, m3);
  134.  
  135. if ((testeA2 >= 0 && testeB2 >= 0) || (testeC2 >= 0 && testeD2 >= 0) || (testeE2 >= 0 && testeF2 >= 0)) {
  136.  
  137. opostosOk2 = true;
  138. }
  139.  
  140. String m4 = "";
  141.  
  142. if (opostosOk2) {
  143.  
  144. int buscaM11 = Arrays.binarySearch(moves1, m2);
  145. int buscaM12 = Arrays.binarySearch(moves2, m2);
  146. int buscaM13 = Arrays.binarySearch(moves3, m2);
  147.  
  148. if (buscaM11 >= 0) {
  149.  
  150. m4 = globalMovesMenosMoves1[r.nextInt(4)];
  151.  
  152. } else if (buscaM12 >= 0) {
  153.  
  154. m4 = globalMovesMenosMoves2[r.nextInt(4)];
  155.  
  156. } else if (buscaM13 >= 0) {
  157.  
  158. m4 = globalMovesMenosMoves3[r.nextInt(4)];
  159.  
  160. }
  161.  
  162. } else {
  163.  
  164. do {
  165.  
  166. m4 = globalMoves[r.nextInt(6)];
  167.  
  168. } while (m4 == m3);
  169.  
  170. }
  171.  
  172. //---------------------------------------------------------------------//
  173. boolean opostosOk3 = false;
  174.  
  175. int testeA3 = Arrays.binarySearch(moves1, m3);
  176. int testeB3 = Arrays.binarySearch(moves1, m4);
  177.  
  178. int testeC3 = Arrays.binarySearch(moves2, m3);
  179. int testeD3 = Arrays.binarySearch(moves2, m4);
  180.  
  181. int testeE3 = Arrays.binarySearch(moves3, m3);
  182. int testeF3 = Arrays.binarySearch(moves3, m4);
  183.  
  184. if ((testeA3 >= 0 && testeB3 >= 0) || (testeC3 >= 0 && testeD3 >= 0) || (testeE3 >= 0 && testeF3 >= 0)) {
  185.  
  186. opostosOk3 = true;
  187. }
  188.  
  189. String m5 = "";
  190.  
  191. if (opostosOk3) {
  192.  
  193. int buscaM11 = Arrays.binarySearch(moves1, m3);
  194. int buscaM12 = Arrays.binarySearch(moves2, m3);
  195. int buscaM13 = Arrays.binarySearch(moves3, m3);
  196.  
  197. if (buscaM11 >= 0) {
  198.  
  199. m5 = globalMovesMenosMoves1[r.nextInt(4)];
  200.  
  201. } else if (buscaM12 >= 0) {
  202.  
  203. m5 = globalMovesMenosMoves2[r.nextInt(4)];
  204.  
  205. } else if (buscaM13 >= 0) {
  206.  
  207. m5 = globalMovesMenosMoves3[r.nextInt(4)];
  208.  
  209. }
  210.  
  211. } else {
  212.  
  213. do {
  214.  
  215. m5 = globalMoves[r.nextInt(6)];
  216.  
  217. } while (m5 == m4);
  218.  
  219. }
  220.  
  221. //-------------------------------------------------------------------//
  222. boolean opostosOk4 = false;
  223.  
  224. int testeA4 = Arrays.binarySearch(moves1, m4);
  225. int testeB4 = Arrays.binarySearch(moves1, m5);
  226.  
  227. int testeC4 = Arrays.binarySearch(moves2, m4);
  228. int testeD4 = Arrays.binarySearch(moves2, m5);
  229.  
  230. int testeE4 = Arrays.binarySearch(moves3, m4);
  231. int testeF4 = Arrays.binarySearch(moves3, m5);
  232.  
  233. if ((testeA4 >= 0 && testeB4 >= 0) || (testeC4 >= 0 && testeD4 >= 0) || (testeE4 >= 0 && testeF4 >= 0)) {
  234.  
  235. opostosOk4 = true;
  236. }
  237.  
  238. String m6 = "";
  239.  
  240. if (opostosOk4) {
  241.  
  242. int buscaM11 = Arrays.binarySearch(moves1, m4);
  243. int buscaM12 = Arrays.binarySearch(moves2, m4);
  244. int buscaM13 = Arrays.binarySearch(moves3, m4);
  245.  
  246. if (buscaM11 >= 0) {
  247.  
  248. m6 = globalMovesMenosMoves1[r.nextInt(4)];
  249.  
  250. } else if (buscaM12 >= 0) {
  251.  
  252. m6 = globalMovesMenosMoves2[r.nextInt(4)];
  253.  
  254. } else if (buscaM13 >= 0) {
  255.  
  256. m6 = globalMovesMenosMoves3[r.nextInt(4)];
  257.  
  258. }
  259.  
  260. } else {
  261.  
  262. do {
  263.  
  264. m6 = globalMoves[r.nextInt(6)];
  265.  
  266. } while (m6 == m5);
  267.  
  268. }
  269.  
  270. //-------------------------------------------------------------------//
  271. boolean opostosOk5 = false;
  272.  
  273. int testeA5 = Arrays.binarySearch(moves1, m5);
  274. int testeB5 = Arrays.binarySearch(moves1, m6);
  275.  
  276. int testeC5 = Arrays.binarySearch(moves2, m5);
  277. int testeD5 = Arrays.binarySearch(moves2, m6);
  278.  
  279. int testeE5 = Arrays.binarySearch(moves3, m4);
  280. int testeF5 = Arrays.binarySearch(moves3, m5);
  281.  
  282. if ((testeA5 >= 0 && testeB5 >= 0) || (testeC5 >= 0 && testeD5 >= 0) || (testeE5 >= 0 && testeF5 >= 0)) {
  283.  
  284. opostosOk5 = true;
  285. }
  286.  
  287. String m7 = "";
  288.  
  289. if (opostosOk5) {
  290.  
  291. int buscaM11 = Arrays.binarySearch(moves1, m5);
  292. int buscaM12 = Arrays.binarySearch(moves2, m5);
  293. int buscaM13 = Arrays.binarySearch(moves3, m5);
  294.  
  295. if (buscaM11 >= 0) {
  296.  
  297. m7 = globalMovesMenosMoves1[r.nextInt(4)];
  298.  
  299. } else if (buscaM12 >= 0) {
  300.  
  301. m7 = globalMovesMenosMoves2[r.nextInt(4)];
  302.  
  303. } else if (buscaM13 >= 0) {
  304.  
  305. m7 = globalMovesMenosMoves3[r.nextInt(4)];
  306.  
  307. }
  308.  
  309. } else {
  310.  
  311. do {
  312.  
  313. m7 = globalMoves[r.nextInt(6)];
  314.  
  315. } while (m7 == m6);
  316.  
  317. }
  318.  
  319. //-------------------------------------------------------------------//
  320. boolean opostosOk6 = false;
  321.  
  322. int testeA6 = Arrays.binarySearch(moves1, m6);
  323. int testeB6 = Arrays.binarySearch(moves1, m7);
  324.  
  325. int testeC6 = Arrays.binarySearch(moves2, m6);
  326. int testeD6 = Arrays.binarySearch(moves2, m7);
  327.  
  328. int testeE6 = Arrays.binarySearch(moves3, m6);
  329. int testeF6 = Arrays.binarySearch(moves3, m7);
  330.  
  331. if ((testeA6 >= 0 && testeB6 >= 0) || (testeC6 >= 0 && testeD6 >= 0) || (testeE6 >= 0 && testeF6 >= 0)) {
  332.  
  333. opostosOk6 = true;
  334. }
  335.  
  336. String m8 = "";
  337.  
  338. if (opostosOk6) {
  339.  
  340. int buscaM11 = Arrays.binarySearch(moves1, m6);
  341. int buscaM12 = Arrays.binarySearch(moves2, m6);
  342. int buscaM13 = Arrays.binarySearch(moves3, m6);
  343.  
  344. if (buscaM11 >= 0) {
  345.  
  346. m8 = globalMovesMenosMoves1[r.nextInt(4)];
  347.  
  348. } else if (buscaM12 >= 0) {
  349.  
  350. m8 = globalMovesMenosMoves2[r.nextInt(4)];
  351.  
  352. } else if (buscaM13 >= 0) {
  353.  
  354. m8 = globalMovesMenosMoves3[r.nextInt(4)];
  355.  
  356. }
  357.  
  358. } else {
  359.  
  360. do {
  361.  
  362. m8 = globalMoves[r.nextInt(6)];
  363.  
  364. } while (m8 == m7);
  365.  
  366. }
  367.  
  368. //-------------------------------------------------------------------//
  369. boolean opostosOk7 = false;
  370.  
  371. int testeA7 = Arrays.binarySearch(moves1, m7);
  372. int testeB7 = Arrays.binarySearch(moves1, m8);
  373.  
  374. int testeC7 = Arrays.binarySearch(moves2, m7);
  375. int testeD7 = Arrays.binarySearch(moves2, m8);
  376.  
  377. int testeE7 = Arrays.binarySearch(moves3, m7);
  378. int testeF7 = Arrays.binarySearch(moves3, m8);
  379.  
  380. if ((testeA7 >= 0 && testeB7 >= 0) || (testeC7 >= 0 && testeD7 >= 0) || (testeE7 >= 0 && testeF7 >= 0)) {
  381.  
  382. opostosOk7 = true;
  383. }
  384.  
  385. String m9 = "";
  386.  
  387. if (opostosOk7) {
  388.  
  389. int buscaM11 = Arrays.binarySearch(moves1, m7);
  390. int buscaM12 = Arrays.binarySearch(moves2, m7);
  391. int buscaM13 = Arrays.binarySearch(moves3, m7);
  392.  
  393. if (buscaM11 >= 0) {
  394.  
  395. m9 = globalMovesMenosMoves1[r.nextInt(4)];
  396.  
  397. } else if (buscaM12 >= 0) {
  398.  
  399. m9 = globalMovesMenosMoves2[r.nextInt(4)];
  400.  
  401. } else if (buscaM13 >= 0) {
  402.  
  403. m9 = globalMovesMenosMoves3[r.nextInt(4)];
  404.  
  405. }
  406.  
  407. } else {
  408.  
  409. do {
  410.  
  411. m9 = globalMoves[r.nextInt(6)];
  412.  
  413. } while (m9 == m8);
  414.  
  415. }
  416.  
  417. //-------------------------------------------------------------------//
  418. boolean opostosOk8 = false;
  419.  
  420. int testeA8 = Arrays.binarySearch(moves1, m8);
  421. int testeB8 = Arrays.binarySearch(moves1, m9);
  422.  
  423. int testeC8 = Arrays.binarySearch(moves2, m8);
  424. int testeD8 = Arrays.binarySearch(moves2, m9);
  425.  
  426. int testeE8 = Arrays.binarySearch(moves3, m8);
  427. int testeF8 = Arrays.binarySearch(moves3, m9);
  428.  
  429. if ((testeA8 >= 0 && testeB8 >= 0) || (testeC8 >= 0 && testeD8 >= 0) || (testeE8 >= 0 && testeF8 >= 0)) {
  430.  
  431. opostosOk8 = true;
  432. }
  433.  
  434. String m10 = "";
  435.  
  436. if (opostosOk8) {
  437.  
  438. int buscaM11 = Arrays.binarySearch(moves1, m8);
  439. int buscaM12 = Arrays.binarySearch(moves2, m8);
  440. int buscaM13 = Arrays.binarySearch(moves3, m8);
  441.  
  442. if (buscaM11 >= 0) {
  443.  
  444. m10 = globalMovesMenosMoves1[r.nextInt(4)];
  445.  
  446. } else if (buscaM12 >= 0) {
  447.  
  448. m10 = globalMovesMenosMoves2[r.nextInt(4)];
  449.  
  450. } else if (buscaM13 >= 0) {
  451.  
  452. m10 = globalMovesMenosMoves3[r.nextInt(4)];
  453.  
  454. }
  455.  
  456. } else {
  457.  
  458. do {
  459.  
  460. m10 = globalMoves[r.nextInt(6)];
  461.  
  462. } while (m10 == m9);
  463.  
  464. }
  465.  
  466. //-------------------------------------------------------------------//
  467. boolean opostosOk9 = false;
  468.  
  469. int testeA9 = Arrays.binarySearch(moves1, m9);
  470. int testeB9 = Arrays.binarySearch(moves1, m10);
  471.  
  472. int testeC9 = Arrays.binarySearch(moves2, m9);
  473. int testeD9 = Arrays.binarySearch(moves2, m10);
  474.  
  475. int testeE9 = Arrays.binarySearch(moves3, m9);
  476. int testeF9 = Arrays.binarySearch(moves3, m10);
  477.  
  478. if ((testeA9 >= 0 && testeB9 >= 0) || (testeC9 >= 0 && testeD9 >= 0) || (testeE9 >= 0 && testeF9 >= 0)) {
  479.  
  480. opostosOk9 = true;
  481. }
  482.  
  483. String m11 = "";
  484.  
  485. if (opostosOk9) {
  486.  
  487. int buscaM11 = Arrays.binarySearch(moves1, m9);
  488. int buscaM12 = Arrays.binarySearch(moves2, m9);
  489. int buscaM13 = Arrays.binarySearch(moves3, m9);
  490.  
  491. if (buscaM11 >= 0) {
  492.  
  493. m11 = globalMovesMenosMoves1[r.nextInt(4)];
  494.  
  495. } else if (buscaM12 >= 0) {
  496.  
  497. m11 = globalMovesMenosMoves2[r.nextInt(4)];
  498.  
  499. } else if (buscaM13 >= 0) {
  500.  
  501. m11 = globalMovesMenosMoves3[r.nextInt(4)];
  502.  
  503. }
  504.  
  505. } else {
  506.  
  507. do {
  508.  
  509. m11 = globalMoves[r.nextInt(6)];
  510.  
  511. } while (m11 == m10);
  512.  
  513. }
  514.  
  515. //-------------------------------------------------------------------//
  516. boolean opostosOk10 = false;
  517.  
  518. int testeA10 = Arrays.binarySearch(moves1, m10);
  519. int testeB10 = Arrays.binarySearch(moves1, m11);
  520.  
  521. int testeC10 = Arrays.binarySearch(moves2, m10);
  522. int testeD10 = Arrays.binarySearch(moves2, m11);
  523.  
  524. int testeE10 = Arrays.binarySearch(moves3, m10);
  525. int testeF10 = Arrays.binarySearch(moves3, m11);
  526.  
  527. if ((testeA10 >= 0 && testeB10 >= 0) || (testeC10 >= 0 && testeD10 >= 0) || (testeE10 >= 0 && testeF10 >= 0)) {
  528.  
  529. opostosOk10 = true;
  530. }
  531.  
  532. String m12 = "";
  533.  
  534. if (opostosOk10) {
  535.  
  536. int buscaM11 = Arrays.binarySearch(moves1, m10);
  537. int buscaM12 = Arrays.binarySearch(moves2, m10);
  538. int buscaM13 = Arrays.binarySearch(moves3, m10);
  539.  
  540. if (buscaM11 >= 0) {
  541.  
  542. m12 = globalMovesMenosMoves1[r.nextInt(4)];
  543.  
  544. } else if (buscaM12 >= 0) {
  545.  
  546. m12 = globalMovesMenosMoves2[r.nextInt(4)];
  547.  
  548. } else if (buscaM13 >= 0) {
  549.  
  550. m12 = globalMovesMenosMoves3[r.nextInt(4)];
  551.  
  552. }
  553.  
  554. } else {
  555.  
  556. do {
  557.  
  558. m12 = globalMoves[r.nextInt(6)];
  559.  
  560. } while (m12 == m11);
  561.  
  562. }
  563.  
  564. //-------------------------------------------------------------------//
  565. boolean opostosOk11 = false;
  566.  
  567. int testeA11 = Arrays.binarySearch(moves1, m11);
  568. int testeB11 = Arrays.binarySearch(moves1, m12);
  569.  
  570. int testeC11 = Arrays.binarySearch(moves2, m11);
  571. int testeD11 = Arrays.binarySearch(moves2, m12);
  572.  
  573. int testeE11 = Arrays.binarySearch(moves3, m11);
  574. int testeF11 = Arrays.binarySearch(moves3, m12);
  575.  
  576. if ((testeA11 >= 0 && testeB11 >= 0) || (testeC11 >= 0 && testeD11 >= 0) || (testeE11 >= 0 && testeF11 >= 0)) {
  577.  
  578. opostosOk11 = true;
  579. }
  580.  
  581. String m13 = "";
  582.  
  583. if (opostosOk11) {
  584.  
  585. int buscaM11 = Arrays.binarySearch(moves1, m11);
  586. int buscaM12 = Arrays.binarySearch(moves2, m11);
  587. int buscaM13 = Arrays.binarySearch(moves3, m11);
  588.  
  589. if (buscaM11 >= 0) {
  590.  
  591. m13 = globalMovesMenosMoves1[r.nextInt(4)];
  592.  
  593. } else if (buscaM12 >= 0) {
  594.  
  595. m13 = globalMovesMenosMoves2[r.nextInt(4)];
  596.  
  597. } else if (buscaM13 >= 0) {
  598.  
  599. m13 = globalMovesMenosMoves3[r.nextInt(4)];
  600.  
  601. }
  602.  
  603. } else {
  604.  
  605. do {
  606.  
  607. m13 = globalMoves[r.nextInt(6)];
  608.  
  609. } while (m13 == m12);
  610.  
  611. }
  612.  
  613. //-------------------------------------------------------------------//
  614. boolean opostosOk12 = false;
  615.  
  616. int testeA12 = Arrays.binarySearch(moves1, m12);
  617. int testeB12 = Arrays.binarySearch(moves1, m13);
  618.  
  619. int testeC12 = Arrays.binarySearch(moves2, m12);
  620. int testeD12 = Arrays.binarySearch(moves2, m13);
  621.  
  622. int testeE12 = Arrays.binarySearch(moves3, m12);
  623. int testeF12 = Arrays.binarySearch(moves3, m13);
  624.  
  625. if ((testeA12 >= 0 && testeB12 >= 0) || (testeC12 >= 0 && testeD12 >= 0) || (testeE12 >= 0 && testeF12 >= 0)) {
  626.  
  627. opostosOk12 = true;
  628. }
  629.  
  630. String m14 = "";
  631.  
  632. if (opostosOk12) {
  633.  
  634. int buscaM11 = Arrays.binarySearch(moves1, m12);
  635. int buscaM12 = Arrays.binarySearch(moves2, m12);
  636. int buscaM13 = Arrays.binarySearch(moves3, m12);
  637.  
  638. if (buscaM11 >= 0) {
  639.  
  640. m14 = globalMovesMenosMoves1[r.nextInt(4)];
  641.  
  642. } else if (buscaM12 >= 0) {
  643.  
  644. m14 = globalMovesMenosMoves2[r.nextInt(4)];
  645.  
  646. } else if (buscaM13 >= 0) {
  647.  
  648. m14 = globalMovesMenosMoves3[r.nextInt(4)];
  649.  
  650. }
  651.  
  652. } else {
  653.  
  654. do {
  655.  
  656. m14 = globalMoves[r.nextInt(6)];
  657.  
  658. } while (m14 == m13);
  659.  
  660. }
  661.  
  662. //-------------------------------------------------------------------//
  663. boolean opostosOk13 = false;
  664.  
  665. int testeA13 = Arrays.binarySearch(moves1, m13);
  666. int testeB13 = Arrays.binarySearch(moves1, m14);
  667.  
  668. int testeC13 = Arrays.binarySearch(moves2, m13);
  669. int testeD13 = Arrays.binarySearch(moves2, m14);
  670.  
  671. int testeE13 = Arrays.binarySearch(moves3, m13);
  672. int testeF13 = Arrays.binarySearch(moves3, m14);
  673.  
  674. if ((testeA13 >= 0 && testeB13 >= 0) || (testeC13 >= 0 && testeD13 >= 0) || (testeE13 >= 0 && testeF13 >= 0)) {
  675.  
  676. opostosOk13 = true;
  677. }
  678.  
  679. String m15 = "";
  680.  
  681. if (opostosOk13) {
  682.  
  683. int buscaM11 = Arrays.binarySearch(moves1, m13);
  684. int buscaM12 = Arrays.binarySearch(moves2, m13);
  685. int buscaM13 = Arrays.binarySearch(moves3, m13);
  686.  
  687. if (buscaM11 >= 0) {
  688.  
  689. m15 = globalMovesMenosMoves1[r.nextInt(4)];
  690.  
  691. } else if (buscaM12 >= 0) {
  692.  
  693. m15 = globalMovesMenosMoves2[r.nextInt(4)];
  694.  
  695. } else if (buscaM13 >= 0) {
  696.  
  697. m15 = globalMovesMenosMoves3[r.nextInt(4)];
  698.  
  699. }
  700.  
  701. } else {
  702.  
  703. do {
  704.  
  705. m15 = globalMoves[r.nextInt(6)];
  706.  
  707. } while (m15 == m14);
  708.  
  709. }
  710.  
  711. //-------------------------------------------------------------------//
  712. boolean opostosOk14 = false;
  713.  
  714. int testeA14 = Arrays.binarySearch(moves1, m14);
  715. int testeB14 = Arrays.binarySearch(moves1, m15);
  716.  
  717. int testeC14 = Arrays.binarySearch(moves2, m14);
  718. int testeD14 = Arrays.binarySearch(moves2, m15);
  719.  
  720. int testeE14 = Arrays.binarySearch(moves3, m14);
  721. int testeF14 = Arrays.binarySearch(moves3, m15);
  722.  
  723. if ((testeA14 >= 0 && testeB14 >= 0) || (testeC14 >= 0 && testeD14 >= 0) || (testeE14 >= 0 && testeF14 >= 0)) {
  724.  
  725. opostosOk14 = true;
  726. }
  727.  
  728. String m16 = "";
  729.  
  730. if (opostosOk14) {
  731.  
  732. int buscaM11 = Arrays.binarySearch(moves1, m14);
  733. int buscaM12 = Arrays.binarySearch(moves2, m14);
  734. int buscaM13 = Arrays.binarySearch(moves3, m14);
  735.  
  736. if (buscaM11 >= 0) {
  737.  
  738. m16 = globalMovesMenosMoves1[r.nextInt(4)];
  739.  
  740. } else if (buscaM12 >= 0) {
  741.  
  742. m16 = globalMovesMenosMoves2[r.nextInt(4)];
  743.  
  744. } else if (buscaM13 >= 0) {
  745.  
  746. m16 = globalMovesMenosMoves3[r.nextInt(4)];
  747.  
  748. }
  749.  
  750. } else {
  751.  
  752. do {
  753.  
  754. m16 = globalMoves[r.nextInt(6)];
  755.  
  756. } while (m16 == m15);
  757.  
  758. }
  759.  
  760. //-------------------------------------------------------------------//
  761. boolean opostosOk15 = false;
  762.  
  763. int testeA15 = Arrays.binarySearch(moves1, m15);
  764. int testeB15 = Arrays.binarySearch(moves1, m16);
  765.  
  766. int testeC15 = Arrays.binarySearch(moves2, m15);
  767. int testeD15 = Arrays.binarySearch(moves2, m16);
  768.  
  769. int testeE15 = Arrays.binarySearch(moves3, m15);
  770. int testeF15 = Arrays.binarySearch(moves3, m16);
  771.  
  772. if ((testeA15 >= 0 && testeB15 >= 0) || (testeC15 >= 0 && testeD15 >= 0) || (testeE15 >= 0 && testeF15 >= 0)) {
  773.  
  774. opostosOk15 = true;
  775. }
  776.  
  777. String m17 = "";
  778.  
  779. if (opostosOk15) {
  780.  
  781. int buscaM11 = Arrays.binarySearch(moves1, m15);
  782. int buscaM12 = Arrays.binarySearch(moves2, m15);
  783. int buscaM13 = Arrays.binarySearch(moves3, m15);
  784.  
  785. if (buscaM11 >= 0) {
  786.  
  787. m17 = globalMovesMenosMoves1[r.nextInt(4)];
  788.  
  789. } else if (buscaM12 >= 0) {
  790.  
  791. m17 = globalMovesMenosMoves2[r.nextInt(4)];
  792.  
  793. } else if (buscaM13 >= 0) {
  794.  
  795. m17 = globalMovesMenosMoves3[r.nextInt(4)];
  796.  
  797. }
  798.  
  799. } else {
  800.  
  801. do {
  802.  
  803. m17 = globalMoves[r.nextInt(6)];
  804.  
  805. } while (m17 == m16);
  806.  
  807. }
  808.  
  809. //-------------------------------------------------------------------//
  810. boolean opostosOk16 = false;
  811.  
  812. int testeA16 = Arrays.binarySearch(moves1, m16);
  813. int testeB16 = Arrays.binarySearch(moves1, m17);
  814.  
  815. int testeC16 = Arrays.binarySearch(moves2, m16);
  816. int testeD16 = Arrays.binarySearch(moves2, m17);
  817.  
  818. int testeE16 = Arrays.binarySearch(moves3, m16);
  819. int testeF16 = Arrays.binarySearch(moves3, m17);
  820.  
  821. if ((testeA16 >= 0 && testeB16 >= 0) || (testeC16 >= 0 && testeD16 >= 0) || (testeE16 >= 0 && testeF16 >= 0)) {
  822.  
  823. opostosOk16 = true;
  824. }
  825.  
  826. String m18 = "";
  827.  
  828. if (opostosOk16) {
  829.  
  830. int buscaM11 = Arrays.binarySearch(moves1, m16);
  831. int buscaM12 = Arrays.binarySearch(moves2, m16);
  832. int buscaM13 = Arrays.binarySearch(moves3, m16);
  833.  
  834. if (buscaM11 >= 0) {
  835.  
  836. m18 = globalMovesMenosMoves1[r.nextInt(4)];
  837.  
  838. } else if (buscaM12 >= 0) {
  839.  
  840. m18 = globalMovesMenosMoves2[r.nextInt(4)];
  841.  
  842. } else if (buscaM13 >= 0) {
  843.  
  844. m18 = globalMovesMenosMoves3[r.nextInt(4)];
  845.  
  846. }
  847.  
  848. } else {
  849.  
  850. do {
  851.  
  852. m18 = globalMoves[r.nextInt(6)];
  853.  
  854. } while (m18 == m17);
  855.  
  856. }
  857.  
  858. //-------------------------------------------------------------------//
  859. boolean opostosOk17 = false;
  860.  
  861. int testeA17 = Arrays.binarySearch(moves1, m17);
  862. int testeB17 = Arrays.binarySearch(moves1, m18);
  863.  
  864. int testeC17 = Arrays.binarySearch(moves2, m17);
  865. int testeD17 = Arrays.binarySearch(moves2, m18);
  866.  
  867. int testeE17 = Arrays.binarySearch(moves3, m17);
  868. int testeF17 = Arrays.binarySearch(moves3, m18);
  869.  
  870. if ((testeA17 >= 0 && testeB17 >= 0) || (testeC17 >= 0 && testeD17 >= 0) || (testeE17 >= 0 && testeF17 >= 0)) {
  871.  
  872. opostosOk17 = true;
  873. }
  874.  
  875. String m19 = "";
  876.  
  877. if (opostosOk17) {
  878.  
  879. int buscaM11 = Arrays.binarySearch(moves1, m17);
  880. int buscaM12 = Arrays.binarySearch(moves2, m17);
  881. int buscaM13 = Arrays.binarySearch(moves3, m17);
  882.  
  883. if (buscaM11 >= 0) {
  884.  
  885. m19 = globalMovesMenosMoves1[r.nextInt(4)];
  886.  
  887. } else if (buscaM12 >= 0) {
  888.  
  889. m19 = globalMovesMenosMoves2[r.nextInt(4)];
  890.  
  891. } else if (buscaM13 >= 0) {
  892.  
  893. m19 = globalMovesMenosMoves3[r.nextInt(4)];
  894.  
  895. }
  896.  
  897. } else {
  898.  
  899. do {
  900.  
  901. m19 = globalMoves[r.nextInt(6)];
  902.  
  903. } while (m19 == m18);
  904.  
  905. }
  906.  
  907. //-------------------------------------------------------------------//
  908. boolean opostosOk18 = false;
  909.  
  910. int testeA18 = Arrays.binarySearch(moves1, m18);
  911. int testeB18 = Arrays.binarySearch(moves1, m19);
  912.  
  913. int testeC18 = Arrays.binarySearch(moves2, m18);
  914. int testeD18 = Arrays.binarySearch(moves2, m19);
  915.  
  916. int testeE18 = Arrays.binarySearch(moves3, m18);
  917. int testeF18 = Arrays.binarySearch(moves3, m19);
  918.  
  919. if ((testeA18 >= 0 && testeB18 >= 0) || (testeC18 >= 0 && testeD18 >= 0) || (testeE18 >= 0 && testeF18 >= 0)) {
  920.  
  921. opostosOk18 = true;
  922. }
  923.  
  924. String m20 = "";
  925.  
  926. if (opostosOk18) {
  927.  
  928. int buscaM11 = Arrays.binarySearch(moves1, m18);
  929. int buscaM12 = Arrays.binarySearch(moves2, m18);
  930. int buscaM13 = Arrays.binarySearch(moves3, m18);
  931.  
  932. if (buscaM11 >= 0) {
  933.  
  934. m20 = globalMovesMenosMoves1[r.nextInt(4)];
  935.  
  936. } else if (buscaM12 >= 0) {
  937.  
  938. m20 = globalMovesMenosMoves2[r.nextInt(4)];
  939.  
  940. } else if (buscaM13 >= 0) {
  941.  
  942. m20 = globalMovesMenosMoves3[r.nextInt(4)];
  943.  
  944. }
  945.  
  946. } else {
  947.  
  948. do {
  949.  
  950. m20 = globalMoves[r.nextInt(6)];
  951.  
  952. } while (m20 == m19);
  953.  
  954. }
  955.  
  956. //-------------------------------------------------------------------//
  957. boolean opostosOk19 = false;
  958.  
  959. int testeA19 = Arrays.binarySearch(moves1, m19);
  960. int testeB19 = Arrays.binarySearch(moves1, m20);
  961.  
  962. int testeC19 = Arrays.binarySearch(moves2, m19);
  963. int testeD19 = Arrays.binarySearch(moves2, m20);
  964.  
  965. int testeE19 = Arrays.binarySearch(moves3, m19);
  966. int testeF19 = Arrays.binarySearch(moves3, m20);
  967.  
  968. if ((testeA19 >= 0 && testeB19 >= 0) || (testeC19 >= 0 && testeD19 >= 0) || (testeE19 >= 0 && testeF19 >= 0)) {
  969.  
  970. opostosOk19 = true;
  971. }
  972.  
  973. String m21 = "";
  974.  
  975. if (opostosOk19) {
  976.  
  977. int buscaM11 = Arrays.binarySearch(moves1, m19);
  978. int buscaM12 = Arrays.binarySearch(moves2, m19);
  979. int buscaM13 = Arrays.binarySearch(moves3, m19);
  980.  
  981. if (buscaM11 >= 0) {
  982.  
  983. m21 = globalMovesMenosMoves1[r.nextInt(4)];
  984.  
  985. } else if (buscaM12 >= 0) {
  986.  
  987. m21 = globalMovesMenosMoves2[r.nextInt(4)];
  988.  
  989. } else if (buscaM13 >= 0) {
  990.  
  991. m21 = globalMovesMenosMoves3[r.nextInt(4)];
  992.  
  993. }
  994.  
  995. } else {
  996.  
  997. do {
  998.  
  999. m21 = globalMoves[r.nextInt(6)];
  1000.  
  1001. } while (m21 == m20);
  1002.  
  1003. }
  1004.  
  1005. //-------------------------------------------------------------------//
  1006. boolean opostosOk20 = false;
  1007.  
  1008. int testeA20 = Arrays.binarySearch(moves1, m20);
  1009. int testeB20 = Arrays.binarySearch(moves1, m21);
  1010.  
  1011. int testeC20 = Arrays.binarySearch(moves2, m20);
  1012. int testeD20 = Arrays.binarySearch(moves2, m21);
  1013.  
  1014. int testeE20 = Arrays.binarySearch(moves3, m20);
  1015. int testeF20 = Arrays.binarySearch(moves3, m21);
  1016.  
  1017. if ((testeA20 >= 0 && testeB20 >= 0) || (testeC20 >= 0 && testeD20 >= 0) || (testeE20 >= 0 && testeF20 >= 0)) {
  1018.  
  1019. opostosOk20 = true;
  1020. }
  1021.  
  1022. String m22 = "";
  1023.  
  1024. if (opostosOk20) {
  1025.  
  1026. int buscaM11 = Arrays.binarySearch(moves1, m20);
  1027. int buscaM12 = Arrays.binarySearch(moves2, m20);
  1028. int buscaM13 = Arrays.binarySearch(moves3, m20);
  1029.  
  1030. if (buscaM11 >= 0) {
  1031.  
  1032. m22 = globalMovesMenosMoves1[r.nextInt(4)];
  1033.  
  1034. } else if (buscaM12 >= 0) {
  1035.  
  1036. m22 = globalMovesMenosMoves2[r.nextInt(4)];
  1037.  
  1038. } else if (buscaM13 >= 0) {
  1039.  
  1040. m22 = globalMovesMenosMoves3[r.nextInt(4)];
  1041.  
  1042. }
  1043.  
  1044. } else {
  1045.  
  1046. do {
  1047.  
  1048. m22 = globalMoves[r.nextInt(6)];
  1049.  
  1050. } while (m22 == m21);
  1051.  
  1052. }
  1053.  
  1054. //-------------------------------------------------------------------//
  1055. boolean opostosOk21 = false;
  1056.  
  1057. int testeA21 = Arrays.binarySearch(moves1, m21);
  1058. int testeB21 = Arrays.binarySearch(moves1, m22);
  1059.  
  1060. int testeC21 = Arrays.binarySearch(moves2, m21);
  1061. int testeD21 = Arrays.binarySearch(moves2, m22);
  1062.  
  1063. int testeE21 = Arrays.binarySearch(moves3, m21);
  1064. int testeF21 = Arrays.binarySearch(moves3, m22);
  1065.  
  1066. if ((testeA21 >= 0 && testeB21 >= 0) || (testeC21 >= 0 && testeD21 >= 0) || (testeE21 >= 0 && testeF21 >= 0)) {
  1067.  
  1068. opostosOk21 = true;
  1069. }
  1070.  
  1071. String m23 = "";
  1072.  
  1073. if (opostosOk21) {
  1074.  
  1075. int buscaM11 = Arrays.binarySearch(moves1, m21);
  1076. int buscaM12 = Arrays.binarySearch(moves2, m21);
  1077. int buscaM13 = Arrays.binarySearch(moves3, m21);
  1078.  
  1079. if (buscaM11 >= 0) {
  1080.  
  1081. m23 = globalMovesMenosMoves1[r.nextInt(4)];
  1082.  
  1083. } else if (buscaM12 >= 0) {
  1084.  
  1085. m23 = globalMovesMenosMoves2[r.nextInt(4)];
  1086.  
  1087. } else if (buscaM13 >= 0) {
  1088.  
  1089. m23 = globalMovesMenosMoves3[r.nextInt(4)];
  1090.  
  1091. }
  1092.  
  1093. } else {
  1094.  
  1095. do {
  1096.  
  1097. m23 = globalMoves[r.nextInt(6)];
  1098.  
  1099. } while (m23 == m22);
  1100.  
  1101. }
  1102.  
  1103. //-------------------------------------------------------------------//
  1104. boolean opostosOk22 = false;
  1105.  
  1106. int testeA22 = Arrays.binarySearch(moves1, m22);
  1107. int testeB22 = Arrays.binarySearch(moves1, m23);
  1108.  
  1109. int testeC22 = Arrays.binarySearch(moves2, m22);
  1110. int testeD22 = Arrays.binarySearch(moves2, m23);
  1111.  
  1112. int testeE22 = Arrays.binarySearch(moves3, m22);
  1113. int testeF22 = Arrays.binarySearch(moves3, m23);
  1114.  
  1115. if ((testeA22 >= 0 && testeB22 >= 0) || (testeC22 >= 0 && testeD22 >= 0) || (testeE22 >= 0 && testeF22 >= 0)) {
  1116.  
  1117. opostosOk22 = true;
  1118. }
  1119.  
  1120. String m24 = "";
  1121.  
  1122. if (opostosOk22) {
  1123.  
  1124. int buscaM11 = Arrays.binarySearch(moves1, m22);
  1125. int buscaM12 = Arrays.binarySearch(moves2, m22);
  1126. int buscaM13 = Arrays.binarySearch(moves3, m22);
  1127.  
  1128. if (buscaM11 >= 0) {
  1129.  
  1130. m24 = globalMovesMenosMoves1[r.nextInt(4)];
  1131.  
  1132. } else if (buscaM12 >= 0) {
  1133.  
  1134. m24 = globalMovesMenosMoves2[r.nextInt(4)];
  1135.  
  1136. } else if (buscaM13 >= 0) {
  1137.  
  1138. m24 = globalMovesMenosMoves3[r.nextInt(4)];
  1139.  
  1140. }
  1141.  
  1142. } else {
  1143.  
  1144. do {
  1145.  
  1146. m24 = globalMoves[r.nextInt(6)];
  1147.  
  1148. } while (m24 == m23);
  1149.  
  1150. }
  1151.  
  1152. //-------------------------------------------------------------------//
  1153. boolean opostosOk23 = false;
  1154.  
  1155. int testeA23 = Arrays.binarySearch(moves1, m23);
  1156. int testeB23 = Arrays.binarySearch(moves1, m24);
  1157.  
  1158. int testeC23 = Arrays.binarySearch(moves2, m23);
  1159. int testeD23 = Arrays.binarySearch(moves2, m24);
  1160.  
  1161. int testeE23 = Arrays.binarySearch(moves3, m23);
  1162. int testeF23 = Arrays.binarySearch(moves3, m24);
  1163.  
  1164. if ((testeA23 >= 0 && testeB23 >= 0) || (testeC23 >= 0 && testeD23 >= 0) || (testeE23 >= 0 && testeF23 >= 0)) {
  1165.  
  1166. opostosOk23 = true;
  1167. }
  1168.  
  1169. String m25 = "";
  1170.  
  1171. if (opostosOk23) {
  1172.  
  1173. int buscaM11 = Arrays.binarySearch(moves1, m23);
  1174. int buscaM12 = Arrays.binarySearch(moves2, m23);
  1175. int buscaM13 = Arrays.binarySearch(moves3, m23);
  1176.  
  1177. if (buscaM11 >= 0) {
  1178.  
  1179. m25 = globalMovesMenosMoves1[r.nextInt(4)];
  1180.  
  1181. } else if (buscaM12 >= 0) {
  1182.  
  1183. m25 = globalMovesMenosMoves2[r.nextInt(4)];
  1184.  
  1185. } else if (buscaM13 >= 0) {
  1186.  
  1187. m25 = globalMovesMenosMoves3[r.nextInt(4)];
  1188.  
  1189. }
  1190.  
  1191. } else {
  1192.  
  1193. do {
  1194.  
  1195. m25 = globalMoves[r.nextInt(6)];
  1196.  
  1197. } while (m25 == m24);
  1198.  
  1199. }
  1200.  
  1201. //-------------------------------------------------------------------//
  1202. System.out.println(
  1203. m1 + mm1 + m2 + mm2 + m3 + mm3 + m4 + mm4 + m5 +
  1204. mm5 + m6 + mm6 + m7 + mm7 + m8 + mm8 + m9 + mm9 + m10
  1205. + mm10 + m11 + mm11 + m12 + mm12 + m13 + mm13 + m14 +
  1206. mm14 + m15 + mm15 + m16+ mm16 + m17 + mm17 + m18 +
  1207. mm18 + m19 + mm19 + m20 + mm20 + m21 + mm21 + m22 +
  1208. mm22 + m23 + mm23 + m24+ mm24 + m25 + mm25
  1209. );
  1210.  
  1211. System.out.println();
  1212.  
  1213. System.out.println("------------------------------------------------------------------------");
  1214.  
  1215. } else if (resposta.contains("2x2")) {
  1216.  
  1217. String[] moves1 = {"F", "U", "R"};
  1218. String[] moves2 = {" ", "' "};
  1219. Random r = new Random();
  1220. String s = "";
  1221. String f = "";
  1222. for (int i = 0; i < 8; i++) {
  1223.  
  1224. do {
  1225. f = moves1[r.nextInt(3)];
  1226.  
  1227. } while (f == s);
  1228. s = f;
  1229. System.out.print(s);
  1230.  
  1231. String u = moves2[r.nextInt(2)];
  1232. System.out.print(u);
  1233.  
  1234. }
  1235.  
  1236. System.out.println();
  1237.  
  1238. System.out.println("------------------------------------------------------------------------");
  1239.  
  1240. } else if (resposta.contains("skewb")) {
  1241.  
  1242. String[] moves1 = {"B", "U", "R", "L"};
  1243. String[] moves3 = {" ", "' "};
  1244. Random r = new Random();
  1245. String s = "";
  1246. String f = "";
  1247. for (int i = 0; i < 12; i++) {
  1248.  
  1249. do {
  1250. f = moves1[r.nextInt(4)];
  1251. } while (f == s);
  1252.  
  1253. s = f;
  1254. System.out.print(s);
  1255.  
  1256. String u = moves3[r.nextInt(2)];
  1257. System.out.print(u);
  1258.  
  1259. }
  1260. System.out.println();
  1261.  
  1262. System.out.println("------------------------------------------------------------------------");
  1263.  
  1264. } else {
  1265.  
  1266. System.out.println("------------------------------------------------------------------------");
  1267.  
  1268. String[] moves1 = {"++", "--"};
  1269. String[] moves2 = {"U", "U'"};
  1270. Random r = new Random();
  1271. for (int j = 0; j < 8; j++) {
  1272. for (int i = 0; i < 11; i++) {
  1273.  
  1274. if (i % 2 == 0) {
  1275. System.out.print("R");
  1276. } else {
  1277. System.out.print("D");
  1278. }
  1279.  
  1280. String s = moves1[r.nextInt(2)];
  1281. System.out.print(s + " ");
  1282.  
  1283. if (i == 10) {
  1284. String u = moves2[r.nextInt(2)];
  1285. System.out.println(u);
  1286. }
  1287. }
  1288. }
  1289. System.out.println("------------------------------------------------------------------------");
  1290.  
  1291. }
  1292.  
  1293. System.out.println("Está pronto? Pressione Enter para começar a contagem de tempo!");
  1294. String estouPronto = digitação.nextLine();
  1295.  
  1296. long começo = System.currentTimeMillis();
  1297.  
  1298. System.out.println("TEMPO CORRENDO! MONTA SAPORRA AÊEEEE"); //gambiarra para manter o programa em execução durante a solve;
  1299. String prolongamentoDeExecução = digitação.nextLine(); //apenas para que usuário dê Enter e o programa continue para a próxima etapa;
  1300.  
  1301. long segundos = (System.currentTimeMillis() - começo) / 1000;
  1302. // long centesimoFinal = (System.currentTimeMillis() -(System.currentTimeMillis() - começo) / 1000) / 100;
  1303.  
  1304. tempoTotal = tempoTotal + segundos;
  1305.  
  1306. long minutoFinal = segundos / 60;
  1307. segundos = segundos % 60;
  1308.  
  1309. //System.out.println("Resolveu em: " + segundoFinal + "." + centesimoFinal + " segundos!");
  1310. if (segundos == 1) {
  1311.  
  1312. System.out.println("Resolveu em: 0" + segundos);
  1313.  
  1314. } else if (segundos < 10) {
  1315.  
  1316. System.out.println("Resolveu em: " + minutoFinal + ": 0" + segundos);
  1317.  
  1318. } else {
  1319.  
  1320. System.out.println("Resolveu em: " + minutoFinal + ": " + segundos);
  1321.  
  1322. }
  1323.  
  1324. System.out.println("------------------------------------------------------------------------");
  1325.  
  1326. double media = tempoTotal / solvesCounter;
  1327.  
  1328. double mediaMinuto = media / 60;
  1329. double mediaSegundo = media % 60;
  1330. int minuto = (int) mediaMinuto;
  1331. int segundo = (int) mediaSegundo;
  1332. if (mediaSegundo == 1) {
  1333.  
  1334. System.out.println("Média: 0" + mediaSegundo);
  1335.  
  1336. } else if (mediaSegundo < 10) {
  1337.  
  1338. System.out.println("Sua média: " + minuto + ": 0" + segundo);
  1339. System.out.println("------------------------------------------------------------------------");
  1340.  
  1341. } else {
  1342.  
  1343. System.out.println("Sua média: " + minuto + ": " + segundo);
  1344. System.out.println("------------------------------------------------------------------------");
  1345.  
  1346. }
  1347. }
  1348.  
  1349. }
  1350.  
  1351. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement