Advertisement
Guest User

Untitled

a guest
May 1st, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.17 KB | None | 0 0
  1. package ayhaga;
  2.  
  3. import org.eclipse.swt.widgets.Display;
  4. import java.io.*;
  5. import org.eclipse.swt.widgets.Shell;
  6. import org.eclipse.swt.widgets.Label;
  7. import org.eclipse.swt.SWT;
  8. //import org.eclipse.wb.swt.SWTResourceManager;
  9.  
  10. import com.sun.java.swing.plaf.windows.resources.windows;
  11.  
  12. import org.eclipse.swt.widgets.Text;
  13. import org.eclipse.swt.widgets.List;
  14. import org.eclipse.swt.widgets.Table;
  15.  
  16. import java.util.ArrayList;
  17. import java.util.Collections;
  18. import java.util.Scanner;
  19.  
  20. import org.eclipse.jface.dialogs.MessageDialog;
  21. import org.eclipse.jface.viewers.TableViewer;
  22. import org.eclipse.swt.custom.CCombo;
  23. import org.eclipse.swt.widgets.Button;
  24. import org.eclipse.swt.events.SelectionAdapter;
  25. import org.eclipse.swt.events.SelectionEvent;
  26. import org.eclipse.swt.layout.GridLayout;
  27. import org.eclipse.wb.swt.SWTResourceManager;
  28. public class Hi {
  29.  
  30. static ArrayList<Integer> minTerms = new ArrayList<Integer>();
  31. static ArrayList<Integer> dontCare = new ArrayList<Integer>();
  32. static int bits, numOfMins, numOfDonts;
  33. static boolean taken[] = new boolean[10000000];
  34. static ArrayList<String> minTermInBinary = new ArrayList<String>();
  35. static ArrayList<String> dontCareInBinary = new ArrayList<String>();
  36. static ArrayList<ArrayList<String>> table = new ArrayList<ArrayList<String>>();
  37. static ArrayList<ArrayList<ArrayList<Integer>>> int_table = new ArrayList<ArrayList<ArrayList<Integer>>>();
  38. static ArrayList<ArrayList<String>> secondaryTable = new ArrayList<ArrayList<String>>();
  39. static ArrayList<ArrayList<ArrayList<Integer>>> int_secondarytable = new ArrayList<ArrayList<ArrayList<Integer>>>();
  40. static boolean toPrimes[][] = new boolean[200][1000];
  41. static ArrayList<String> primeImplicants = new ArrayList<String>();
  42. static ArrayList<ArrayList<Integer>> intPrimeImplicants = new ArrayList<ArrayList<Integer>>();
  43. static int numToBeTaken = -1;
  44. static int numOfOccurence[] = new int[200000];
  45. static ArrayList<ArrayList<String>> resMinSOP = new ArrayList<ArrayList<String>>();
  46. static boolean isMinTerm[] = new boolean[200000];
  47.  
  48. //
  49. static ArrayList<String> Steps = new ArrayList<String>();
  50. static int nSteps = 0;
  51. static ArrayList<String> finalResult = new ArrayList<String>();
  52.  
  53. protected Shell shlSwtApplication;
  54. private Text minterms;
  55. private Button btnNewButton;
  56. private Button btnExit;
  57. private Text finalanswer;
  58. private Button btnNewButton_1;
  59. private Text dontcares;
  60. private Button btnShowSteps;
  61.  
  62. /**
  63. * Launch the application.
  64. *
  65. * @param args
  66. */
  67. public static void main(String[] args) {
  68. try {
  69. Hi window = new Hi();
  70. window.open();
  71. } catch (Exception e) {
  72. e.printStackTrace();
  73. }
  74. }
  75.  
  76. /**
  77. * Open the window.
  78. */
  79. public void open() {
  80. Display display = Display.getDefault();
  81. createContents();
  82. shlSwtApplication.open();
  83. shlSwtApplication.layout();
  84. while (!shlSwtApplication.isDisposed()) {
  85. if (!display.readAndDispatch()) {
  86. display.sleep();
  87. }
  88. }
  89. }
  90.  
  91. /**
  92. * Create contents of the window.
  93. */
  94. protected void createContents() {
  95.  
  96. shlSwtApplication = new Shell();
  97. shlSwtApplication.setSize(717, 476);
  98. shlSwtApplication.setText("Quin Solver");
  99.  
  100. Label Welcoming = new Label(shlSwtApplication, SWT.NONE);
  101. Welcoming.setFont(SWTResourceManager.getFont("Traditional Arabic", 31, SWT.NORMAL));
  102. Welcoming.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
  103. Welcoming.setForeground(SWTResourceManager.getColor(SWT.COLOR_GREEN));
  104. Welcoming.setForeground(SWTResourceManager.getColor(SWT.COLOR_GREEN));
  105. Welcoming.setAlignment(SWT.CENTER);
  106. Welcoming.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_FOREGROUND));
  107. Welcoming.setFont(SWTResourceManager.getFont("OCR A Extended", 38, SWT.BOLD));
  108. Welcoming.setBounds(10, 24, 681, 103);
  109. Welcoming.setText("\u2764\uD83D\uDC38 Quine McClusky \uD83D\uDC38\u2764\r\n\u2764\uD83D\uDC38 Solver \uD83D\uDC38\u2764");
  110.  
  111. minterms = new Text(shlSwtApplication, SWT.BORDER);
  112. minterms.setBounds(20, 174, 419, 25);
  113.  
  114. Label lblNewLabel = new Label(shlSwtApplication, SWT.NONE);
  115. lblNewLabel.setFont(SWTResourceManager.getFont("Segoe UI", 16, SWT.NORMAL));
  116. lblNewLabel.setBounds(20, 133, 212, 35);
  117. lblNewLabel.setText("Enter MinTerms Here :");
  118.  
  119. Label lblNewLabel_1 = new Label(shlSwtApplication, SWT.NONE);
  120. lblNewLabel_1.setFont(SWTResourceManager.getFont("Segoe UI", 16, SWT.NORMAL));
  121. lblNewLabel_1.setBounds(20, 205, 230, 35);
  122. lblNewLabel_1.setText("Enter Don't Cares Here :");
  123.  
  124. btnNewButton = new Button(shlSwtApplication, SWT.NONE);
  125. btnNewButton.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
  126. btnNewButton.addSelectionListener(new SelectionAdapter() {
  127. @Override
  128. public void widgetSelected(SelectionEvent e) {
  129. try {
  130. String min = minterms.getText();
  131. String dont = dontcares.getText();
  132. reset();
  133. DoIt(dont, min);
  134. finalanswer.setText(finalResult.get(0));
  135. } catch (Exception e1) {
  136. MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Warning",
  137. "Input should be between 0 & 2^19 - 1 without duplicates");
  138. }
  139.  
  140. }
  141. });
  142. btnNewButton.setBounds(20, 287, 75, 25);
  143. btnNewButton.setText("Solve !");
  144.  
  145. btnExit = new Button(shlSwtApplication, SWT.NONE);
  146. btnExit.addSelectionListener(new SelectionAdapter() {
  147. @Override
  148. public void widgetSelected(SelectionEvent e) {
  149. shlSwtApplication.close();
  150. }
  151. });
  152. btnExit.setBounds(616, 402, 75, 25);
  153. btnExit.setText("Exit");
  154.  
  155. finalanswer = new Text(shlSwtApplication, SWT.BORDER | SWT.V_SCROLL);
  156. finalanswer.setBounds(23, 321, 587, 106);
  157.  
  158. btnNewButton_1 = new Button(shlSwtApplication, SWT.NONE);
  159. btnNewButton_1.addSelectionListener(new SelectionAdapter() {
  160. @Override
  161. public void widgetSelected(SelectionEvent e) {
  162. try {
  163. String min = minterms.getText();
  164. String dont = dontcares.getText();
  165. reset();
  166. DoIt(dont, min);
  167. finalanswer.setText("");
  168. String s = new String();
  169. for (int i = 0; i < finalResult.size(); i++) {
  170. s = finalResult.get(i);
  171. finalanswer.append(s + "\n");
  172. }
  173. } catch (Exception e1) {
  174. MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Warning",
  175. "Input should be between 0 & 2^19 - 1 without duplicates");
  176. }
  177. }
  178. });
  179. btnNewButton_1.setBounds(136, 287, 138, 25);
  180. btnNewButton_1.setText("Show All Answers");
  181.  
  182. dontcares = new Text(shlSwtApplication, SWT.BORDER);
  183. dontcares.setBounds(20, 245, 419, 25);
  184.  
  185. btnShowSteps = new Button(shlSwtApplication, SWT.NONE);
  186. btnShowSteps.addSelectionListener(new SelectionAdapter() {
  187. @Override
  188. public void widgetSelected(SelectionEvent e) {
  189. try {
  190. String min = minterms.getText();
  191. String dont = dontcares.getText();
  192. reset();
  193. DoIt(dont, min);
  194. finalanswer.setText("");
  195. String s = new String();
  196. for (int i = 0; i < Steps.size(); i++) {
  197. s = Steps.get(i);
  198. finalanswer.append(s + "\n");
  199. }
  200. } catch (Exception e1) {
  201. MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Warning",
  202. "Input should be between 0 & 2^19 - 1 without duplicates");
  203. }
  204. }
  205. });
  206. btnShowSteps.setBounds(322, 287, 75, 25);
  207. btnShowSteps.setText("Show Steps");
  208.  
  209. }
  210.  
  211. public static void reset() {
  212. minTerms = new ArrayList<Integer>();
  213. dontCare = new ArrayList<Integer>();
  214. taken = new boolean[10000];
  215. minTermInBinary = new ArrayList<String>();
  216. dontCareInBinary = new ArrayList<String>();
  217. table = new ArrayList<ArrayList<String>>();
  218. int_table = new ArrayList<ArrayList<ArrayList<Integer>>>();
  219. secondaryTable = new ArrayList<ArrayList<String>>();
  220. int_secondarytable = new ArrayList<ArrayList<ArrayList<Integer>>>();
  221. toPrimes = new boolean[200][1000];
  222. primeImplicants = new ArrayList<String>();
  223. intPrimeImplicants = new ArrayList<ArrayList<Integer>>();
  224. numToBeTaken = -1;
  225. numOfOccurence = new int[200000];
  226. resMinSOP = new ArrayList<ArrayList<String>>();
  227. isMinTerm = new boolean[200000];
  228.  
  229. //
  230. Steps = new ArrayList<String>();
  231. nSteps = 0;
  232. finalResult = new ArrayList<String>();
  233. }
  234.  
  235. public static void DoIt(String dont, String min) {
  236. resetIsTaken();
  237. String str = new String();
  238. String val = new String();
  239. int max = 0;
  240. for (int counter = 0; counter < min.length(); counter++) {
  241. if (!Character.isDigit(min.charAt(counter)) && min.charAt(counter) != ' ')
  242. throw new RuntimeException();
  243. else if (min.charAt(counter) == ' ') {
  244. str += "*";
  245. } else
  246. str += min.charAt(counter);
  247. }
  248. str += "*";
  249. for (int counter = 0; counter < str.length(); counter++) {
  250. if (str.charAt(counter) != '*')
  251. val += str.charAt(counter);
  252. if (str.charAt(counter) != '*' && str.charAt(counter + 1) == '*') {
  253. int temp = Integer.parseInt(val);
  254. if (temp > Math.pow(2, 19))
  255. throw new RuntimeException();
  256. if (taken[temp]) {
  257. throw new RuntimeException();
  258. }
  259. taken[temp] = true;
  260. max = Math.max(temp, max);
  261. minTerms.add(temp);
  262. val = new String();
  263. }
  264. }
  265. String forBits = Integer.toBinaryString(max);
  266. bits = forBits.length();
  267. str = new String();
  268. val = new String();
  269. for (int counter = 0; counter < dont.length(); counter++) {
  270. if (!Character.isDigit(dont.charAt(counter)) && dont.charAt(counter) != ' ')
  271. throw new RuntimeException();
  272. else if (dont.charAt(counter) == ' ') {
  273. str += "*";
  274. } else
  275. str += dont.charAt(counter);
  276. }
  277. str += "*";
  278. for (int counter = 0; counter < str.length(); counter++) {
  279. if (str.charAt(counter) != '*')
  280. val += str.charAt(counter);
  281. if (str.charAt(counter) != '*' && str.charAt(counter + 1) == '*') {
  282. int temp = Integer.parseInt(val);
  283. if (temp > Math.pow(2, 19))
  284. throw new RuntimeException();
  285. if (taken[temp]) {
  286. throw new RuntimeException();
  287. }
  288. taken[temp] = true;
  289. dontCare.add(temp);
  290. val = new String();
  291. }
  292. }
  293. numOfMins = minTerms.size();
  294. numOfDonts = dontCare.size();
  295. for (int i = 0; i < numOfMins; i++) {
  296. minTermInBinary.add(Integer.toBinaryString(minTerms.get(i)));
  297. while (minTermInBinary.get(i).length() < bits)
  298. minTermInBinary.set(i, "0" + minTermInBinary.get(i));
  299. }
  300.  
  301. for (int i = 0; i < numOfDonts; i++) {
  302. dontCareInBinary.add(Integer.toBinaryString(dontCare.get(i)));
  303. while (dontCareInBinary.get(i).length() < bits)
  304. dontCareInBinary.set(i, "0" + dontCareInBinary.get(i));
  305. }
  306.  
  307. for (int i = 0; i < numOfDonts; i++) {
  308. minTermInBinary.add(dontCareInBinary.get(i));
  309. minTerms.add(dontCare.get(i));
  310. }
  311.  
  312. for (int i = 0; i < numOfMins; i++)
  313. isMinTerm[minTerms.get(i)] = true;
  314.  
  315. getTheTable();
  316. printSteps();
  317. while (compare()) {
  318. checkTheUntakenElements();
  319. table.clear();
  320. int_table.clear();
  321. table = new ArrayList<ArrayList<String>>(secondaryTable);
  322. int_table = new ArrayList<ArrayList<ArrayList<Integer>>>(int_secondarytable);
  323. printSteps();
  324. }
  325. putInPrimeImplicants();
  326. removeDuplicates();
  327. printPrimeImplicants();
  328. calculateNumOfOccurrence();
  329. ArrayList<String> building = new ArrayList<String>();
  330. while (true) {
  331. numToBeTaken = -1;
  332. directGetofPrimeImp();
  333. if (numToBeTaken == -1)
  334. break;
  335. building.add(addDirectSOP());
  336. }
  337. planB(building);
  338. removeDuplicatesFromTheResult();
  339. String Hamada = new String();
  340. for (int i = 0; i < resMinSOP.size(); i++) {
  341. Hamada += (resMinSOP.get(i) + " ");
  342. if (i != resMinSOP.size() - 1)
  343. Hamada += (", ");
  344. }
  345. Steps.add(Hamada);
  346. printResult();
  347. }
  348.  
  349. /**
  350. * setting the value of taken numbers to false again
  351. */
  352. static void resetIsTaken() {
  353. for (int i = 0; i < 10000; i++)
  354. taken[i] = false;
  355. }
  356.  
  357. /**
  358. * setting the first table to be minimized later
  359. */
  360. static void getTheTable() {
  361. for (int numOfOnes = 0; numOfOnes <= bits; numOfOnes++) {
  362. ArrayList<String> subArray = new ArrayList<String>();
  363. ArrayList<ArrayList<Integer>> subInt = new ArrayList<ArrayList<Integer>>();
  364. for (int i = 0; i < numOfMins + numOfDonts; i++) {
  365. int temp = 0;
  366. for (int j = 0; j < bits; j++) {
  367. if (minTermInBinary.get(i).charAt(j) == '1')
  368. temp++;
  369. }
  370. if (temp == numOfOnes) {
  371. subArray.add(minTermInBinary.get(i));
  372. ArrayList<Integer> tempo = new ArrayList<Integer>();
  373. tempo.add(minTerms.get(i));
  374. subInt.add(tempo);
  375. }
  376. }
  377. if (subArray.size() != 0) {
  378. table.add(subArray);
  379. int_table.add(subInt);
  380. }
  381. }
  382. System.out.println(table.size());
  383. }
  384.  
  385. static void printSteps() {
  386. for (int i = 0; i < table.size(); i++) {
  387. for (int j = 0; j < table.get(i).size(); j++) {
  388. Steps.add("-->" + int_table.get(i).get(j) + " " + table.get(i).get(j));
  389. }
  390. }
  391. Steps.add("=====================================");
  392. }
  393.  
  394. static void printPrimeImplicants() {
  395. for (int i = 0; i < primeImplicants.size(); i++) {
  396. Steps.add("-->" + intPrimeImplicants.get(i) + " " + primeImplicants.get(i));
  397. }
  398. }
  399.  
  400. static void resetTakenPrimes() {
  401. for (int i = 0; i < 200; i++)
  402. for (int j = 0; j < 1000; j++)
  403. toPrimes[i][j] = false;
  404. }
  405.  
  406. static boolean compare() {
  407. resetTakenPrimes();
  408. boolean ok = false;
  409. secondaryTable.clear();
  410. int_secondarytable.clear();
  411. for (int i = 0; i < table.size() - 1; i++) {
  412. ArrayList<ArrayList<Integer>> subInt = new ArrayList<ArrayList<Integer>>();
  413. ArrayList<String> subBinary = new ArrayList<String>();
  414. for (int j = 0; j < table.get(i).size(); j++) {
  415. for (int k = 0; k < table.get(i + 1).size(); k++) {
  416. int numOfDiff = 0, index = 0;
  417. for (int l = 0; l < bits; l++) {
  418. if (table.get(i).get(j).charAt(l) != table.get(i + 1).get(k).charAt(l)
  419. && Character.isDigit(table.get(i).get(j).charAt(l))
  420. && Character.isDigit(table.get(i + 1).get(k).charAt(l))) {
  421. numOfDiff++;
  422. index = l;
  423. }
  424. }
  425. boolean skip = false;
  426. for (int p = 0; p < bits; p++)
  427. if (checkDashes(table.get(i).get(j).charAt(p), table.get(i + 1).get(k).charAt(p)))
  428. skip = true;
  429. if (numOfDiff == 1 && !skip) {
  430. toPrimes[i][j] = toPrimes[i + 1][k] = true;
  431. subBinary.add(table.get(i).get(j).substring(0, index) + "-"
  432. + table.get(i).get(j).substring(index + 1, bits));
  433. ArrayList<Integer> temp = new ArrayList<Integer>();
  434. for (int l = 0; l < int_table.get(i).get(j).size(); l++)
  435. temp.add(int_table.get(i).get(j).get(l));
  436. for (int l = 0; l < int_table.get(i + 1).get(k).size(); l++)
  437. temp.add(int_table.get(i + 1).get(k).get(l));
  438. subInt.add(temp);
  439. ok = true;
  440. }
  441. }
  442. }
  443. if (subBinary.size() > 0) {
  444. secondaryTable.add(subBinary);
  445. int_secondarytable.add(subInt);
  446. }
  447. }
  448.  
  449. return ok;
  450. }
  451.  
  452. static boolean checkDashes(char a, char b) {
  453. return (a == '-' && b != '-') || (a != '-' && b == '-');
  454. }
  455.  
  456. static void checkTheUntakenElements() {
  457. for (int i = 0; i < table.size(); i++) {
  458. for (int j = 0; j < table.get(i).size(); j++) {
  459. if (!toPrimes[i][j]) {
  460. primeImplicants.add(table.get(i).get(j));
  461. intPrimeImplicants.add(int_table.get(i).get(j));
  462. }
  463. }
  464. }
  465. }
  466.  
  467. static void putInPrimeImplicants() {
  468. for (int i = 0; i < table.size(); i++) {
  469. for (int j = 0; j < table.get(i).size(); j++) {
  470. primeImplicants.add(table.get(i).get(j));
  471. intPrimeImplicants.add(int_table.get(i).get(j));
  472. }
  473. }
  474. }
  475.  
  476. static void removeDuplicates() {
  477. String ifRepeated;
  478. for (int i = 0; i < primeImplicants.size() - 1; i++) {
  479. ifRepeated = primeImplicants.get(i);
  480. for (int j = primeImplicants.size() - 1; j > i; j--) {
  481. if (ifRepeated.equals(primeImplicants.get(j))) {
  482. primeImplicants.remove(j);
  483. intPrimeImplicants.remove(j);
  484. }
  485. }
  486. }
  487. }
  488.  
  489. static void calculateNumOfOccurrence() {
  490. for (int i = 0; i < 200000; i++)
  491. numOfOccurence[i] = 0;
  492. for (int i = 0; i < intPrimeImplicants.size(); i++)
  493. for (int j = 0; j < intPrimeImplicants.get(i).size(); j++)
  494. if (isMinTerm[intPrimeImplicants.get(i).get(j)])
  495. numOfOccurence[intPrimeImplicants.get(i).get(j)]++;
  496. }
  497.  
  498. static boolean directGetofPrimeImp() {
  499. boolean cont = false;
  500. for (int i = 0; i < Math.pow(2, bits); i++) {
  501. if (numOfOccurence[i] == 1 && isMinTerm[i])
  502. numToBeTaken = i;
  503. if (numOfOccurence[i] != 0 && isMinTerm[i])
  504. cont = true;
  505. }
  506. return cont;
  507. }
  508.  
  509. static String addDirectSOP() {
  510. String ret = "";
  511. for (int i = 0; i < intPrimeImplicants.size(); i++) {
  512. for (int j = 0; j < intPrimeImplicants.get(i).size(); j++) {
  513. if (intPrimeImplicants.get(i).get(j) == numToBeTaken) {
  514. ret = primeImplicants.get(i);
  515. for (int k = 0; k < intPrimeImplicants.get(i).size(); k++)
  516. numOfOccurence[intPrimeImplicants.get(i).get(k)] = 0;
  517. }
  518. }
  519. }
  520. return ret;
  521. }
  522. static void planB(ArrayList<String> x) {
  523. if (!directGetofPrimeImp()) {
  524. if (resMinSOP.size() == 0 || resMinSOP.get(resMinSOP.size() - 1).size() == x.size()) {
  525. resMinSOP.add(x);
  526. } else if (x.size() < resMinSOP.get(resMinSOP.size() - 1).size()) {
  527. resMinSOP.clear();
  528. resMinSOP.add(x);
  529. }
  530. return;
  531. }
  532. ArrayList<String> res = new ArrayList<String>(x);
  533. for (int i = 0; i < intPrimeImplicants.size(); i++) {
  534. int temp = 0;
  535. res = new ArrayList<String>(x);
  536. for (int j = 0; j < intPrimeImplicants.get(i).size(); j++) {
  537. if (numOfOccurence[intPrimeImplicants.get(i).get(j)] != 0
  538. && isMinTerm[intPrimeImplicants.get(i).get(j)])
  539. temp++;
  540. }
  541. if(temp != 0){
  542. boolean takenIndices[] = new boolean[intPrimeImplicants.get(i).size() + 3];
  543. for (int k = 0; k < intPrimeImplicants.get(i).size(); k++) {
  544. if (numOfOccurence[intPrimeImplicants.get(i).get(k)] != 0) {
  545. numOfOccurence[intPrimeImplicants.get(i).get(k)] = 0;
  546. takenIndices[k] = true;
  547. }
  548. }
  549. res.add(primeImplicants.get(i));
  550. planB(res);
  551. for (int k = 0; k < intPrimeImplicants.get(i).size(); k++) {
  552. if (takenIndices[k]) {
  553. numOfOccurence[intPrimeImplicants.get(i).get(k)] = 2;
  554. }
  555. }
  556. }
  557. }
  558.  
  559.  
  560. }
  561. static boolean isDashes() {
  562. for (int i = 0; i < resMinSOP.get(0).get(0).length(); i++) {
  563. if (resMinSOP.get(0).get(0).charAt(i) != '-')
  564. return false;
  565. }
  566. return true;
  567. }
  568.  
  569. static void removeDuplicatesFromTheResult() {
  570. for (int i = 0; i < resMinSOP.size(); i++) {
  571. ArrayList<String> dup = new ArrayList<String>(resMinSOP.get(i));
  572. ArrayList<String> toBeRemoved;
  573. Collections.sort(dup);
  574. for (int j = resMinSOP.size() - 1; j > i; j--) {
  575. toBeRemoved = new ArrayList<String>(resMinSOP.get(j));
  576. Collections.sort(toBeRemoved);
  577. if (dup.equals(toBeRemoved))
  578. resMinSOP.remove(j);
  579. }
  580. }
  581. }
  582.  
  583. static void printResult() {
  584. if (resMinSOP.get(0).size() == 1 && isDashes()) {
  585. finalResult.add("1");
  586. } else {
  587. for (int i = 0; i < resMinSOP.size(); i++) {
  588. String Mo2men = new String();
  589. for (int k = 0; k < resMinSOP.get(i).size(); k++) {
  590. for (int j = 0; j < bits; j++) {
  591. if (resMinSOP.get(i).get(k).charAt(j) == '0') {
  592. Mo2men += ((char) (j + 65));
  593. Mo2men += ("\'");
  594. } else if (resMinSOP.get(i).get(k).charAt(j) == '1')
  595. Mo2men += ((char) (j + 65));
  596. }
  597. if (k != resMinSOP.get(i).size() - 1)
  598. Mo2men += (" + ");
  599. }
  600. finalResult.add(Mo2men);
  601. }
  602. }
  603. }
  604. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement