the problem is to order an array that contains 2n pairs of letters of the form BA but can not be ordered in an ordinary way, it has to be ordered by moving block from to 2 (I can not move just one letter)
example n = 4: BABABABA
public void emparejarAAyBB(int pos){ // pos = posicion a remplazar
System.out.println("PAREJA AB");
int bloqueAux = tomarUltimoAB();
moverBloque(bloqueAux,pos);
System.out.println("PAREJA BA");
int aux2 = tomarPrimerBA();
moverBloque(aux2,bloqueAux);
if(tomarUltimoAB()!=-1){ // si hay otro bloque AB que cumpla los requisitos se repite el ciclo
emparejarAAyBB(aux2);
}
ordenarParejas(aux2);
}
I tried to find a pattern when ordering but I could not do it. Now I think to solve it by brute force, I realized that in every step there are always n possible movements and that the minimum number of movements is n. So there would be possible paths which I do not know how to save them.