private boolean listContainsEquation( ArrayList<Element> list, ArrayList<Element> equationElement) { ArrayList<Element> listClone = list.clone(); for (Element element : equationElement) { if (listClone.contains(element)) listClone.remove(element); else return false; } return true; }
private ArrayList<Element> sortList(ArrayList<Element> list) { ArrayList<Element> listSorted = new ArrayList<>(); ArrayList<Element> elements = new ArrayList<>(Element.values()); for (Element element : elements) while (list.contains(element)) { list.remove(element); listSorted.add(element); } return listSorted; }
public boolean isPerfectPosition(ArrayList<Element> list) { for (ArrayList<Element> pPosition : this.perfectPositions) { if (pPosition.size() != list.size()) continue; ArrayList<Element> listTemp = list.clone(); boolean notFound = false; for (Element element : pPosition) if (listTemp.contains(element)) listTemp.remove(element); else notFound = true; if (notFound) continue; if (!listTemp.isEmpty()) continue; return true; } return false; }