I can have a composition of N elements in an array that can be arranged as follows:
array with A, B, C and D ... 12 possibilities.
arr1 = ["A|B","A|C","A|D","B|A","B|C","B|D","C|A","C|B","C|D","D|A","D|B","D|C"];
array with A, B, and C ... 9 possibilities.
arr2 = ["A","B","C","A|B","A|C","B|A","B|C","C|A","C|B"];
I need to create a draw so that I do not have to repeat one of the elements, exp:
arrDeSaida = ["B|A","D|C"]; //Válido
arrDeSaida = ["B|A","A|C"]; //inválido
arrDeSaida = ["B|C","A"]; //Válido
arrDeSaida = ["B|A","B"]; //inválido
Logic is simply not fitting ...
qtdElementos = ["A","B","C","D"];
for (var i = 0; i < qtdElementos.length; i++) {
for (var x = 0; x < qtdElementos.length; x++) {
if(x != i){
arr1.push(qtdElementos[i]+'|'+qtdElementos[x]);
}
}
}
for (var i = 0; i <= qtdElementos.length/2; i++) {
if(arr1.length >= 2){
posicao = arr1[i].split("|");
for (var j = ; j < arr1.length; j++) {
}
}
}
I caught within the second for, I do not know what I could do ..