I have k number of Vectors, each containing n number of elements.
I need to implement an algorithm that creates new Vectors in this manner:
e.g.: Given
V1: (e1, e2)
V2: (e3)
V3: (e4, e5, e6)
the desired output would be
newV1: (e1, e3, e4)
newV2: (e1, e3, e5)
newV3: (e1, e3, e6)
newV4: (e2, e3, e4)
and so on until it produces all the possible combinations in this way.
What I have done so far would potentially only work to produce just the first combination for each element of the first Vector (it would only produce newV1
, newV4
, etc):
//compute new subclauses
CNFClause expressionNegatedFinal = new CNFClause();
boolean visited = false;
expressionNegated.getSubclauses().get(0).print();
for (Literal l: expressionNegated.getSubclauses().get(0).getLiterals()) {
CNFSubClause scNF = new CNFSubClause();
scNF.getLiterals().add(l);
for (int j=1; j<expressionNegated.getSubclauses().size(); j++) {
for(Literal li: expressionNegated.getSubclauses().get(j).getLiterals()) {
li.setVisited(true);
scNF.getLiterals().add(li);
break;
}
}
expressionNegatedFinal.getSubclauses().add(scNF);
}
How can I implement this?
Edit1: I need this to work for any k number of vectors greater or equal to 2 and with any n number of elements greater or equal to 1 inside each vector