|
|
@ -662,6 +662,71 @@ function chercherCombinaison() {
|
|
|
|
window.alert("Nombre de combinaison: " + Cptsolution);
|
|
|
|
window.alert("Nombre de combinaison: " + Cptsolution);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
|
|
|
|
printCombinations([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 3);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function printCombinations(array, p) {
|
|
|
|
|
|
|
|
var combinations = [];
|
|
|
|
|
|
|
|
var Cptsolution = 0;
|
|
|
|
|
|
|
|
for (k = 2; k < p + 1; k++) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function run(level, start) {
|
|
|
|
|
|
|
|
for (var i = start; i < array.length - k + level + 1; i++) {
|
|
|
|
|
|
|
|
combinations[level] = array[i];
|
|
|
|
|
|
|
|
//console.log(i);
|
|
|
|
|
|
|
|
if (level < k - 1) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
run(level + 1, i + 1);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var combTest = [];
|
|
|
|
|
|
|
|
for (var j = 0; j < combinations.length; j++) {
|
|
|
|
|
|
|
|
combTest.push(deckPartie[combinations[j]]);
|
|
|
|
|
|
|
|
//window.alert("Matrice ajouté num" + j + " :" + deckPartie[combinations[j]].getMatrice);
|
|
|
|
|
|
|
|
//console.log("i"+j +" :"+ combinations[j]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//console.log("matrice début ex: "+combTest[0].getMatrice);
|
|
|
|
|
|
|
|
console.log("Cartes selectionnées :(en partant de indice 0) :")
|
|
|
|
|
|
|
|
console.log(combinations.join(" "));
|
|
|
|
|
|
|
|
console.log("----- taille :" + combTest.length + " -------");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var cpt = testCombinaison(combTest, combinations, Cptsolution);
|
|
|
|
|
|
|
|
Cptsolution = cpt;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
run(0, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
window.alert("nb combi :" + Cptsolution);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function testCombinaison(DeckTeste, combi, Cptsolution) {
|
|
|
|
|
|
|
|
var tabCode = [];
|
|
|
|
|
|
|
|
var tab = [];
|
|
|
|
|
|
|
|
//window.alert("---------------");
|
|
|
|
|
|
|
|
tab = AssemblageARBRE(copieListeDeCarte(DeckTeste), copieCarte(DeckTeste[0]));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Recupération de code
|
|
|
|
|
|
|
|
var solution = true;
|
|
|
|
|
|
|
|
for (var h = 0; h < tab.length; h++) {
|
|
|
|
|
|
|
|
tabCode.push(tab[h].code);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//Reagarde si il y a une solution
|
|
|
|
|
|
|
|
for (var g = 0; g < tab.length; g++) {
|
|
|
|
|
|
|
|
if (tab[g].code == DeckTeste.length) {
|
|
|
|
|
|
|
|
solution = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//Reagarde si il y a une solution
|
|
|
|
|
|
|
|
if (!solution) {
|
|
|
|
|
|
|
|
Cptsolution++;
|
|
|
|
|
|
|
|
window.alert("Combinaison à " + (DeckTeste.length) + " cartes trouvée : " + combi);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return Cptsolution;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function chercheCombi2() {
|
|
|
|
function chercheCombi2() {
|
|
|
|
|
|
|
|
|
|
|
|
var Cptsolution = 0;
|
|
|
|
var Cptsolution = 0;
|
|
|
|