Fonction recherche 3

master
theo 4 years ago
parent ef35056455
commit 9c6b237fc8

Binary file not shown.

@ -524,6 +524,63 @@ function chercheCombi2() {
window.alert("Nombre de solution à 2 cartes : " + Cptsolution);
}
//=================================================================================
//chercheCombi => Compte les combinainsons de 3 cartes à l'écran
function chercheCombi3() {
var Cptsolution = 0;
for (var i = 0; i < 15; i++) { //Partie fixe
for (var j = 0; j < 15 - i; j++) { //Partie movible 1
for (var k = 0; k < 15 - j; k++) { //Partie movible 2
var DeckTeste = [];
var tabCode = [];
var tab = [];
var copie = [];
copie.splice(0, DeckTeste.length);
DeckTeste.splice(0, DeckTeste.length);
tab.splice(0, DeckTeste.length);
tabCode.splice(0, DeckTeste.length);
DeckTeste.push(deckPartie[i]);
DeckTeste.push(deckPartie[j + i + 1]);
DeckTeste.push(deckPartie[k + j + i + 2]);
for (var h = 0; h < DeckTeste.length; h++) {
copie.push(DeckTeste[i]);
}
for (var z = 0; z < DeckTeste; z++) {
if (DeckTeste[z] == null) {
window.alert("Pb carte null :" + i + j + k);
}
}
tab = AssemblageARBRE(copieListeDeCarte(DeckTeste), copieCarte(DeckTeste[0]));
var solution = true;
for (var h = 0; h < tab.length; h++) {
tabCode.push(tab[h].code);
}
for (var g = 0; g < tab.length; g++) {
if (tab[g].code == DeckTeste.length) {
solution = false;
}
}
if (!solution) {
Cptsolution++;
window.alert("Combinaison a 3 trouvé: " + (i + 1) + " " + (i + j + 2) + " " + (k + j + i + 3));
}
}
}
}
if (Cptsolution == 0) {
window.alert("Pas de solution");
}
window.alert("Nombre de solution à 3 cartes : " + Cptsolution);
}
//=================================================================================

Loading…
Cancel
Save