1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
private ArrayList<int[]> possibilities;
public void nbOfPossibilities(int i, ArrayList<int[]> oldValues){
int oldNbOfLines = oldValues.size();
possibilities = new ArrayList<int[]>();
int[] lineValues;
for(int j=0 ; j<(i+1) ; j++){ // Nb blocks
for(int k=0 ; k<oldNbOfLines ; k++){ //Lignes par block
int indice=0;
lineValues = new int[i+1];
int numLigne = (j*oldNbOfLines)+k;
for(int m=0 ; m<(i+1) ; m++){
// Cas où on est dans le premier block
if(j==0){
if(m==0){
lineValues[m]=i;
}
else{
lineValues[m]=oldValues.get(k)[m-1];
}
}
else{
if(m==j){
lineValues[m]=i;
}
else{
lineValues[m]=oldValues.get(k)[indice];
indice++;
}
}
}
possibilities.add(numLigne, lineValues);
}
}
if(i+1<otherGrayPiecies.size())
nbOfPossibilities(i+1,possibilities);
else
return;
}
public ArrayList<int[]> initNbOfPossibilitiesDefaultValues(){
ArrayList<int[]> valuesList = new ArrayList<int[]>();
int[] values = {0,1};
valuesList.add(0,values);
int[] values2 = {1,0};
valuesList.add(1,values2);
return valuesList;
}
public static void main(String[] args) {
(...)
// Valeurs d'initialisation pour recherche un nombre de cas possibles
ArrayList<int[]> defaultValues = initNbOfPossibilitiesDefaultValues();
nbOfPossibilities(2,defaultValues);
System.out.println("nb combinaisons trouvées : "+possibilities.size());
(...)
} |
Partager