I am trying to find a combination of 6 over 85 possibilities. This would take o(n^6) where N is 85 and would be something like 351 billion calculations. Obviously this would take a very long time to do. There must be a way to do recursively, especially since there would be so many possible duplicate lists (since order doesn't matter) such as: 1, 2, 3, 4, 5, 6 == 1, 2, 3, 4, 6, 5 etc..
public void findOptimal6Combination() {
for(int i = 1; i < list.size(); i++) {
for(int j = 1; j < list.size(); j++) {
if(i != j)
for(int k = 1; k < list.size(); k++) {
if(i != k && j != k)
for(int l = 1; l < list.size(); l++) {
if(i != l && j != l && k != l)
for(int m = 1; m < list.size(); m++) {
if(i != m && j != m && k != m && l != m)
for(int n = 1; n < list.size(); n++) {
if(i != n && j != n && k != n && l != n && m != n) {
current6.add(list.get(i));
current6.add(list.get(j));
current6.add(list.get(k));
current6.add(list.get(l));
current6.add(list.get(m));
current6.add(list.get(n));
performOperation(); //uses the current6 arraylist
}
}
}
}
}
}
}
}