	var PLA = new Array(8)
	var PLB = new Array(8)
	var PLC = new Array(9)
	var PLD = new Array(10)
	var PLE = new Array(11)
	var n = new Array(6)
	var t1, t2
	var sol, trouve, operation, result, essai, difficile, duree, longueur_solution
	var o1, o2, o3, o4, o5, nn,tot
	var nn = 0
	var entertime = 0
	var probleme = 0
	var plaque = new Array(23)
	var flag = new Array(23)
	var nombre = new Array(6)
	var ie
	
function retour(){
		window.history.back()
}
function poser_probleme(){
 		document.COMPTE.resultat.value = ""
 		document.COMPTE.n1.focus()
}
function poser_probleme2(){
 		document.COMPTE.TOTAL.nx.focus()
}
function calculer_solution(){
    nn = 0
	enter=new Date();
	entertime = enter.getTime()
	chrono_long() 

 		document.COMPTE.resultat.value = ""
		trouve = 0
 		n[1] = eval(document.COMPTE.n1.value)
 		n[2] = eval(document.COMPTE.n2.value)
 		n[3] = eval(document.COMPTE.n3.value)
 		n[4] = eval(document.COMPTE.n4.value)
 		n[5] = eval(document.COMPTE.n5.value)
 		n[6] = eval(document.COMPTE.n6.value)
 		nx = eval(document.COMPTE.nx.value)
 		sol = nx
 				A1() ; 
 				if(trouve == 0) {B1()}
 				if(trouve == 0) {C1()}
 				
 		if(navigator.appName == "Microsoft Internet Explorer") ie = true                        
 		if (ie){
 				resoudre()
 		}
 		if(!ie){
 				if(trouve == 0) {essai = 4; D1()}
 				if(trouve == 0) {essai = 5; D1()}
				if(trouve == 0) resoudre()
		}
		window.clearTimeout('chrono_long()')
		afficher_solution()
		document.COMPTE.tirage.focus();	
}

function afficher_solution(){
		if(trouve == 1) document.COMPTE.resultat.value = result;
		else ecrireSol()
		document.COMPTE.tirage.focus();
}


function tirages(){
nn = 0 
	enter=new Date();
	entertime = enter.getTime()
	window.setTimeout('chrono_long()',1000)

	tot = 0; essai =0; trouve = 0;
	
	for (jj= 1; jj<10; jj++) {plaque[jj] = jj}
 		 
  	for (jj= 10; jj<19; jj++){plaque[jj] = jj-9}
 	
 	plaque[19] = 10
 	plaque[20] = 25
 	plaque[21] = 50
 	plaque[22] = 75
 	plaque[23] = 100

 	tot=0;
	
 	do {	
		al = Math.ceil(Math.random() * 22 +1)
		if(tot == 0){ 	
			for (ii = 1; ii < 24; ii++) {flag[ii] = 1}
		}
		
		if(difficile <= 1) {flag[22] = 0}
		if(difficile == 0) {flag[22] = 0 ;flag[23] = 0 }

				
		if(flag[al] == 1) {
			tot = tot+1
			nombre[tot] = plaque[al]
			flag[al] = 0
		}
	}while (tot <=6)

 			sol = Math.ceil(Math.random() * 800) + 200
 			if (difficile == 0) {sol = Math.ceil(Math.random() * 15) + 105}

	
 		document.COMPTE.n1.value = nombre[1]
 		document.COMPTE.n2.value = nombre[2]
 		document.COMPTE.n3.value = nombre[3]
 		document.COMPTE.n4.value = nombre[4]
 		document.COMPTE.n5.value = nombre[5]
 		document.COMPTE.n6.value = nombre[6]
    	document.COMPTE.nx.value = sol
 	 	document.COMPTE.resultat.value = ""
	
	tester_tirage()
	if(tot == 0) {tirages()};	
	
  		if(navigator.appName == "Microsoft Internet Explorer") ie = true                        
 		if (ie){
 				resoudre()
 		}
 		if(!ie){
 				if(trouve == 0) {essai = 4; D1()}
 				if(trouve == 0) {essai = 5; D1()}
				if(trouve == 0) resoudre()
		}
		
	window.clearTimeout('chrono_long()')
	document.COMPTE.solu.focus();
}

function tester_tirage(){
			trouve = 0; tot =0;
 			n[1] = eval(document.COMPTE.n1.value)
 			n[2] = eval(document.COMPTE.n2.value)
 			n[3] = eval(document.COMPTE.n3.value)
 			n[4] = eval(document.COMPTE.n4.value)
 			n[5] = eval(document.COMPTE.n5.value)
 			n[6] = eval(document.COMPTE.n6.value)
 			nx = sol
 			
 			
 			if(difficile == 1) {
 				A1() ; 
 				if(trouve == 1) {tot = 0};
 				if(trouve == 0) {
 					B1() ; 
 					if(trouve == 1) {tot = 6};
 				}		
 			}
 			
 			if(difficile == 2){
 				A1() ; 
 				if(trouve == 1) {tot = 0};
 				if(trouve == 0) {
 					B1() ; 
 					if(trouve == 1) {tot = 0};
 					if(trouve == 0) {
 						C1() ; 
 						if(trouve == 1) {tot = 6}
 					}
 				}
 			}
 			if(difficile == 3){
 				A1() ; 
 				if(trouve == 1) {tot = 0};
 				if(trouve == 0) {
 					B1() ; 
 					if(trouve == 1) {tot = 0};
 					if(trouve == 0) {
 						C1() ; 
 						if(trouve == 1) {tot = 0}
 						if(trouve == 0) {tot = 6} 						
 					}
 				}
 			}
  			if(difficile == 4){
 				A1() ; 
 				if(trouve == 0) {B1()}
 				if(trouve == 0) {C1()}
 				if(trouve == 0) {D1()}
 				tot = 6
 			}			
  			if(difficile == 0){
 				A1() ; 
 				if(trouve == 0) {B1()}
 				if(trouve == 0) {C1()}
 				if(trouve == 1) tot = 6
 			}			
}

 /* Ceci est un commentaire */   
/* --------------------------------------- 1ère opération sur 1 ------------------------------------  */ 
/* --------------------------------------- 1ère opération sur 1 ------------------------------------  */
/* --------------------------------------- 1ère opération sur 1 ------------------------------------  */

function A1(){
	operation = 1; trouve = 0;
                  PLA[1]= n[1];PLA[2]= n[2];PLA[3]= n[3];PLA[4]= n[4];PLA[5]= n[5];PLA[6]= n[6];A2()
    if(trouve==0){PLA[1]= n[1];PLA[2]= n[3];PLA[3]= n[2];PLA[4]= n[4];PLA[5]= n[5];PLA[6]= n[6];A2()}
    if(trouve==0){PLA[1]= n[1];PLA[2]= n[4];PLA[3]= n[2];PLA[4]= n[3];PLA[5]= n[5];PLA[6]= n[6];A2()}
    if(trouve==0){PLA[1]= n[1];PLA[2]= n[5];PLA[3]= n[2];PLA[4]= n[3];PLA[5]= n[4];PLA[6]= n[6];A2()}
    if(trouve==0){PLA[1]= n[1];PLA[2]= n[6];PLA[3]= n[2];PLA[4]= n[3];PLA[5]= n[4];PLA[6]= n[5];A2()}
    if(trouve==0){PLA[1]= n[2];PLA[2]= n[3];PLA[3]= n[1];PLA[4]= n[4];PLA[5]= n[5];PLA[6]= n[6];A2()}
    if(trouve==0){PLA[1]= n[2];PLA[2]= n[4];PLA[3]= n[1];PLA[4]= n[3];PLA[5]= n[5];PLA[6]= n[6];A2()}
    if(trouve==0){PLA[1]= n[2];PLA[2]= n[5];PLA[3]= n[1];PLA[4]= n[3];PLA[5]= n[4];PLA[6]= n[6];A2()}
    if(trouve==0){PLA[1]= n[2];PLA[2]= n[6];PLA[3]= n[1];PLA[4]= n[3];PLA[5]= n[4];PLA[6]= n[5];A2()}
    if(trouve==0){PLA[1]= n[3];PLA[2]= n[4];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[5];PLA[6]= n[6];A2()}
    if(trouve==0){PLA[1]= n[3];PLA[2]= n[5];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[4];PLA[6]= n[6];A2()}
    if(trouve==0){PLA[1]= n[3];PLA[2]= n[6];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[4];PLA[6]= n[5];A2()}
    if(trouve==0){PLA[1]= n[4];PLA[2]= n[5];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[3];PLA[6]= n[6];A2()}
    if(trouve==0){PLA[1]= n[4];PLA[2]= n[6];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[3];PLA[6]= n[5];A2()}
    if(trouve==0){PLA[1]= n[5];PLA[2]= n[6];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[3];PLA[6]= n[4];A2()}
}  

function A2(){

                PLA[7]= PLA[1]+PLA[2]; o1 = " + ";
                               if(PLA[7]== sol) {solution()};
                PLA[7]= Math.abs(PLA[1]- PLA[2]);o1 =" - ";
                               if(PLA[7]== sol) {solution()} ;
        if(PLA[1]== 1  || PLA[2]== 1) {k=1
        }else{          
                PLA[7]= PLA[1]* PLA[2];o1 = " * ";
                                if(PLA[7]== sol) {solution()}; 
                PLA[7]= PLA[1]/ PLA[2];
                                if(PLA[7]== sol) {solution()}; 
                PLA[7]= PLA[2]/ PLA[1];o1 = " / ";
                                if(PLA[7]== sol) {solution()} ;
        }
}
        
/* --------------------------------------- 1ère opération sur 2--------------------------------------- */
/* --------------------------------------- 1ère opération sur 2--------------------------------------- */
/* --------------------------------------- 1ère opération sur 2--------------------------------------- */

function B1(){
	operation = 1; trouve = 0; 
                  PLA[1]= n[1];PLA[2]= n[2];PLA[3]= n[3];PLA[4]= n[4];PLA[5]= n[5];PLA[6]= n[6];B2()
    if(trouve==0){PLA[1]= n[1];PLA[2]= n[3];PLA[3]= n[2];PLA[4]= n[4];PLA[5]= n[5];PLA[6]= n[6];B2()}
    if(trouve==0){PLA[1]= n[1];PLA[2]= n[4];PLA[3]= n[2];PLA[4]= n[3];PLA[5]= n[5];PLA[6]= n[6];B2()}
    if(trouve==0){PLA[1]= n[1];PLA[2]= n[5];PLA[3]= n[2];PLA[4]= n[3];PLA[5]= n[4];PLA[6]= n[6];B2()}
    if(trouve==0){PLA[1]= n[1];PLA[2]= n[6];PLA[3]= n[2];PLA[4]= n[3];PLA[5]= n[4];PLA[6]= n[5];B2()}
    if(trouve==0){PLA[1]= n[2];PLA[2]= n[3];PLA[3]= n[1];PLA[4]= n[4];PLA[5]= n[5];PLA[6]= n[6];B2()}
    if(trouve==0){PLA[1]= n[2];PLA[2]= n[4];PLA[3]= n[1];PLA[4]= n[3];PLA[5]= n[5];PLA[6]= n[6];B2()}
    if(trouve==0){PLA[1]= n[2];PLA[2]= n[5];PLA[3]= n[1];PLA[4]= n[3];PLA[5]= n[4];PLA[6]= n[6];B2()}
    if(trouve==0){PLA[1]= n[2];PLA[2]= n[6];PLA[3]= n[1];PLA[4]= n[3];PLA[5]= n[4];PLA[6]= n[5];B2()}
    if(trouve==0){PLA[1]= n[3];PLA[2]= n[4];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[5];PLA[6]= n[6];B2()}
    if(trouve==0){PLA[1]= n[3];PLA[2]= n[5];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[4];PLA[6]= n[6];B2()}
    if(trouve==0){PLA[1]= n[3];PLA[2]= n[6];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[4];PLA[6]= n[5];B2()}
    if(trouve==0){PLA[1]= n[4];PLA[2]= n[5];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[3];PLA[6]= n[6];B2()}
    if(trouve==0){PLA[1]= n[4];PLA[2]= n[6];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[3];PLA[6]= n[5];B2()}
    if(trouve==0){PLA[1]= n[5];PLA[2]= n[6];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[3];PLA[6]= n[4];B2()}
}  

function B2(){

				PLA[7]= PLA[1]+ PLA[2];o1 = " + ";		B3();
                    
                PLA[7]= PLA[1]- PLA[2];o1 = " - ";
     	if(PLA[7]> 0){ 									B3();
        }else{
        		PLA[7]= PLA[2]- PLA[1];				    B3(); 
        }
                    
        if(PLA[1]== 1  || PLA[2]== 1) {k=1
        }else{         
                PLA[7]= PLA[1]* PLA[2];o1 = " * "; 		B3();
    			
                PLA[7]= PLA[1]/ PLA[2];
                    if(Math.ceil(PLA[7]) == PLA[7]) 	B3();
                    
                PLA[7]= PLA[2]/ PLA[1];o1 = " / ";
                    if(Math.ceil(PLA[7]) == PLA[7])  	B3();
        }
        
}
        
/* --------------------------------------- 2ème opération sur 2--------------------------------------- */

function B3(){
			operation = 2; 
            PLB[3]= PLA[3];PLB[4]= PLA[4];PLB[5]= PLA[5];PLB[6]= PLA[6];PLB[7]= PLA[7];B4();
            PLB[3]= PLA[3];PLB[4]= PLA[5];PLB[5]= PLA[4];PLB[6]= PLA[6];PLB[7]= PLA[7];B4();
            PLB[3]= PLA[3];PLB[4]= PLA[6];PLB[5]= PLA[4];PLB[6]= PLA[5];PLB[7]= PLA[7];B4();
            PLB[3]= PLA[3];PLB[4]= PLA[7];PLB[5]= PLA[4];PLB[6]= PLA[5];PLB[7]= PLA[6];B4();
            PLB[3]= PLA[4];PLB[4]= PLA[5];PLB[5]= PLA[3];PLB[6]= PLA[6];PLB[7]= PLA[7];B4();
            PLB[3]= PLA[4];PLB[4]= PLA[6];PLB[5]= PLA[3];PLB[6]= PLA[5];PLB[7]= PLA[7];B4();
            PLB[3]= PLA[4];PLB[4]= PLA[7];PLB[5]= PLA[3];PLB[6]= PLA[5];PLB[7]= PLA[6];B4();
            PLB[3]= PLA[5];PLB[4]= PLA[6];PLB[5]= PLA[3];PLB[6]= PLA[4];PLB[7]= PLA[7];B4();
            PLB[3]= PLA[5];PLB[4]= PLA[7];PLB[5]= PLA[3];PLB[6]= PLA[4];PLB[7]= PLA[6];B4();
            PLB[3]= PLA[6];PLB[4]= PLA[7];PLB[5]= PLA[3];PLB[6]= PLA[4];PLB[7]= PLA[5];B4();
}

function B4(){

			PLB[8]= PLB[3]+ PLB[4];o2 = " + ";
                				if(PLB[8]== sol) {solution()};
            PLB[8]= Math.abs(PLB[3]- PLB[4]);o2 = " - "; 
                				if(PLB[8]== sol) {solution()};
        if(PLB[3]== 1  || PLB[4]== 1) {k =1      
        }else{
            PLB[8]= PLB[3]* PLB[4];o2 = " * " ;
                				if(PLB[8]== sol) {solution()};
            PLB[8]= PLB[3]/ PLB[4];o2 = " / " ;
                				if(PLB[8]== sol) {solution()} ;
            PLB[8]= PLB[4]/ PLB[3];
                 				if(PLB[8]== sol) {solution()}; 
        }               		
}
/* --------------------------------------- 1ère opération sur 3--------------------------------------- */
/* --------------------------------------- 1ère opération sur 3--------------------------------------- */
/* --------------------------------------- 1ère opération sur 3--------------------------------------- */

function C1(){
	operation = 1
                  PLA[1]= n[1];PLA[2]= n[2];PLA[3]= n[3];PLA[4]= n[4];PLA[5]= n[5];PLA[6]= n[6];C2()
    if(trouve==0){PLA[1]= n[1];PLA[2]= n[3];PLA[3]= n[2];PLA[4]= n[4];PLA[5]= n[5];PLA[6]= n[6];C2()}
    if(trouve==0){PLA[1]= n[1];PLA[2]= n[4];PLA[3]= n[2];PLA[4]= n[3];PLA[5]= n[5];PLA[6]= n[6];C2()}
    if(trouve==0){PLA[1]= n[1];PLA[2]= n[5];PLA[3]= n[2];PLA[4]= n[3];PLA[5]= n[4];PLA[6]= n[6];C2()}
    if(trouve==0){PLA[1]= n[1];PLA[2]= n[6];PLA[3]= n[2];PLA[4]= n[3];PLA[5]= n[4];PLA[6]= n[5];C2()}
    if(trouve==0){PLA[1]= n[2];PLA[2]= n[3];PLA[3]= n[1];PLA[4]= n[4];PLA[5]= n[5];PLA[6]= n[6];C2()}
    if(trouve==0){PLA[1]= n[2];PLA[2]= n[4];PLA[3]= n[1];PLA[4]= n[3];PLA[5]= n[5];PLA[6]= n[6];C2()}
    if(trouve==0){PLA[1]= n[2];PLA[2]= n[5];PLA[3]= n[1];PLA[4]= n[3];PLA[5]= n[4];PLA[6]= n[6];C2()}
    if(trouve==0){PLA[1]= n[2];PLA[2]= n[6];PLA[3]= n[1];PLA[4]= n[3];PLA[5]= n[4];PLA[6]= n[5];C2()}
    if(trouve==0){PLA[1]= n[3];PLA[2]= n[4];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[5];PLA[6]= n[6];C2()}
    if(trouve==0){PLA[1]= n[3];PLA[2]= n[5];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[4];PLA[6]= n[6];C2()}
    if(trouve==0){PLA[1]= n[3];PLA[2]= n[6];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[4];PLA[6]= n[5];C2()}
    if(trouve==0){PLA[1]= n[4];PLA[2]= n[5];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[3];PLA[6]= n[6];C2()}
    if(trouve==0){PLA[1]= n[4];PLA[2]= n[6];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[3];PLA[6]= n[5];C2()}
    if(trouve==0){PLA[1]= n[5];PLA[2]= n[6];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[3];PLA[6]= n[4];C2()}
}  

function C2(){
                PLA[7]= PLA[1]+ PLA[2];o1 = " + ";         	C3();
                PLA[7]= PLA[1]- PLA[2];o1 = " - ";
        if(PLA[7]>0){										C3();
        }else{  
        		PLA[7]= PLA[2]- PLA[1];						C3();
		}
                
        if(PLA[1]== 1  || PLA[2]== 1){k =1
        }else{        
                PLA[7]= PLA[1]* PLA[2];o1 = " * ";         	C3();
                PLA[7]= PLA[1]/ PLA[2];o1 = " / ";
                    if(Math.ceil(PLA[7]) == PLA[7])         C3();
                PLA[7]= PLA[2]/ PLA[1];
                    if(Math.ceil(PLA[7]) == PLA[7])         C3();
       }             
}
/* --------------------------------------- 2ème opération sur 3--------------------------------------- */

function C3(){
	operation = 2

            PLB[3]= PLA[3];PLB[4]= PLA[4];PLB[5]= PLA[5];PLB[6]= PLA[6];PLB[7]= PLA[7];C4()
            PLB[3]= PLA[3];PLB[4]= PLA[5];PLB[5]= PLA[4];PLB[6]= PLA[6];PLB[7]= PLA[7];C4()
            PLB[3]= PLA[3];PLB[4]= PLA[6];PLB[5]= PLA[4];PLB[6]= PLA[5];PLB[7]= PLA[7];C4()
            PLB[3]= PLA[3];PLB[4]= PLA[7];PLB[5]= PLA[4];PLB[6]= PLA[5];PLB[7]= PLA[6];C4()
            PLB[3]= PLA[4];PLB[4]= PLA[5];PLB[5]= PLA[3];PLB[6]= PLA[6];PLB[7]= PLA[7];C4()
            PLB[3]= PLA[4];PLB[4]= PLA[6];PLB[5]= PLA[3];PLB[6]= PLA[5];PLB[7]= PLA[7];C4()
            PLB[3]= PLA[4];PLB[4]= PLA[7];PLB[5]= PLA[3];PLB[6]= PLA[5];PLB[7]= PLA[6];C4()
            PLB[3]= PLA[5];PLB[4]= PLA[6];PLB[5]= PLA[3];PLB[6]= PLA[4];PLB[7]= PLA[7];C4()
            PLB[3]= PLA[5];PLB[4]= PLA[7];PLB[5]= PLA[3];PLB[6]= PLA[4];PLB[7]= PLA[6];C4()
            PLB[3]= PLA[6];PLB[4]= PLA[7];PLB[5]= PLA[3];PLB[6]= PLA[4];PLB[7]= PLA[5];C4()
}

function C4(){
                PLB[8]= PLB[3]+ PLB[4];o2 = " + ";          C5();
                PLB[8]= PLB[3]- PLB[4];o2 = " - ";
   		if(PLB[8]>0){										C5();
        }else{
        		PLB[8]= PLB[4]- PLB[3];						C5();
        }
                
        if(PLB[3]== 1  || PLB[4]== 1) {k =1
        }else{   
                PLB[8]= PLB[3]* PLB[4];o2 = " * ";          C5();
                PLB[8]= PLB[3]/ PLB[4];
                		if(Math.ceil(PLB[8]) == PLB[8])     C5();
                PLB[8]= PLB[4]/ PLB[3];o2 = " / "; 
                		if(Math.ceil(PLB[8]) == PLB[8])     C5();
        }

}
/* --------------------------------------- 3ème opération sur 3 --------------------------------------- */

function C5(){
			operation = 3
            PLC[5]= PLB[5];PLC[6]= PLB[6];PLC[7]= PLB[7];PLC[8]= PLB[8];C6()
            PLC[5]= PLB[5];PLC[6]= PLB[7];PLC[7]= PLB[6];PLC[8]= PLB[8];C6()
            PLC[5]= PLB[5];PLC[6]= PLB[8];PLC[7]= PLB[6];PLC[8]= PLB[7];C6()
            PLC[5]= PLB[6];PLC[6]= PLB[7];PLC[7]= PLB[5];PLC[8]= PLB[8];C6()
            PLC[5]= PLB[6];PLC[6]= PLB[8];PLC[7]= PLB[5];PLC[8]= PLB[7];C6()
            PLC[5]= PLB[7];PLC[6]= PLB[8];PLC[7]= PLB[5];PLC[8]= PLB[6];C6()
}
function C6(){

	            PLC[9]= PLC[5]+ PLC[6];o3 = " + "
	                		if(PLC[9]== sol)                     {solution()};
	        	PLC[9]= Math.abs(PLC[5]- PLC[6]);o3 = " - ";
	                		if(PLC[9]== sol)                     {solution()}; 
	        if(PLC[5]== 1  || PLC[6]== 1){ k =1
        	}else{      
	            PLC[9]= PLC[5]* PLC[6];o3 = " * ";
	                		if(PLC[9]== sol) 					 {solution()};
	            PLC[9]= PLC[5]/ PLC[6];o3 = " / ";
	                		if(PLC[9]== sol)                     {solution()};
	            PLC[9]= PLC[6]/ PLC[5];
	                		if(PLC[9]== sol)                     {solution()};
        	}
}
/* --------------------------------------- 1ère opération sur 4 --------------------------------------- */
/* --------------------------------------- 1ère opération sur 4 --------------------------------------- */
/* --------------------------------------- 1ère opération sur 4 --------------------------------------- */

function D1(){
	operation = 1
                  PLA[1]= n[1];PLA[2]= n[2];PLA[3]= n[3];PLA[4]= n[4];PLA[5]= n[5];PLA[6]= n[6];D1b()
    if(trouve==0){PLA[1]= n[1];PLA[2]= n[3];PLA[3]= n[2];PLA[4]= n[4];PLA[5]= n[5];PLA[6]= n[6];D1b()}
    if(trouve==0){PLA[1]= n[1];PLA[2]= n[4];PLA[3]= n[2];PLA[4]= n[3];PLA[5]= n[5];PLA[6]= n[6];D1b()}
    if(trouve==0){PLA[1]= n[1];PLA[2]= n[5];PLA[3]= n[2];PLA[4]= n[3];PLA[5]= n[4];PLA[6]= n[6];D1b()}
    if(trouve==0){PLA[1]= n[1];PLA[2]= n[6];PLA[3]= n[2];PLA[4]= n[3];PLA[5]= n[4];PLA[6]= n[5];D1b()}
    if(trouve==0){PLA[1]= n[2];PLA[2]= n[3];PLA[3]= n[1];PLA[4]= n[4];PLA[5]= n[5];PLA[6]= n[6];D1b()}
    if(trouve==0){PLA[1]= n[2];PLA[2]= n[4];PLA[3]= n[1];PLA[4]= n[3];PLA[5]= n[5];PLA[6]= n[6];D1b()}
    if(trouve==0){PLA[1]= n[2];PLA[2]= n[5];PLA[3]= n[1];PLA[4]= n[3];PLA[5]= n[4];PLA[6]= n[6];D1b()}
    if(trouve==0){PLA[1]= n[2];PLA[2]= n[6];PLA[3]= n[1];PLA[4]= n[3];PLA[5]= n[4];PLA[6]= n[5];D1b()}
    if(trouve==0){PLA[1]= n[3];PLA[2]= n[4];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[5];PLA[6]= n[6];D1b()}
    if(trouve==0){PLA[1]= n[3];PLA[2]= n[5];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[4];PLA[6]= n[6];D1b()}
    if(trouve==0){PLA[1]= n[3];PLA[2]= n[6];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[4];PLA[6]= n[5];D1b()}
    if(trouve==0){PLA[1]= n[4];PLA[2]= n[5];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[3];PLA[6]= n[6];D1b()}
    if(trouve==0){PLA[1]= n[4];PLA[2]= n[6];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[3];PLA[6]= n[5];D1b()}
    if(trouve==0){PLA[1]= n[5];PLA[2]= n[6];PLA[3]= n[1];PLA[4]= n[2];PLA[5]= n[3];PLA[6]= n[4];D1b()}
}  

function D1b(){
	
                PLA[7]= PLA[1]+ PLA[2];o1 = " + " ;  	D2();
                PLA[7]= PLA[1]- PLA[2];o1 = " - "
      	if(PLA[7]> 0){                      			D2();
        }else{
                PLA[7]= PLA[2]- PLA[1];          		D2();
        }
        if(PLA[1]== 1  || PLA[2]== 1) { k =1
        	}else{          
                PLA[7]= PLA[1]* PLA[2];o1 = " * " ;     D2();
                PLA[7]= PLA[1]/ PLA[2];o1 = " / "
                    if(Math.ceil(PLA[7]) == PLA[7])     D2();
                PLA[7]= PLA[2]/ PLA[1];
                    if(Math.ceil(PLA[7]) == PLA[7])     D2();
        }
}
/* --------------------------------------- 2ème opération sur 4--------------------------------------- */

function D2(){
	operation = 2;
            PLB[3]= PLA[3];PLB[4]= PLA[4];PLB[5]= PLA[5];PLB[6]= PLA[6];PLB[7]= PLA[7];	D2b();
            PLB[3]= PLA[3];PLB[4]= PLA[5];PLB[5]= PLA[4];PLB[6]= PLA[6];PLB[7]= PLA[7];	D2b();
            PLB[3]= PLA[3];PLB[4]= PLA[6];PLB[5]= PLA[4];PLB[6]= PLA[5];PLB[7]= PLA[7];	D2b();
            PLB[3]= PLA[3];PLB[4]= PLA[7];PLB[5]= PLA[4];PLB[6]= PLA[5];PLB[7]= PLA[6];	D2b();
            PLB[3]= PLA[4];PLB[4]= PLA[5];PLB[5]= PLA[3];PLB[6]= PLA[6];PLB[7]= PLA[7];	D2b();
            PLB[3]= PLA[4];PLB[4]= PLA[6];PLB[5]= PLA[3];PLB[6]= PLA[5];PLB[7]= PLA[7];	D2b();
            PLB[3]= PLA[4];PLB[4]= PLA[7];PLB[5]= PLA[3];PLB[6]= PLA[5];PLB[7]= PLA[6];	D2b();
            PLB[3]= PLA[5];PLB[4]= PLA[6];PLB[5]= PLA[3];PLB[6]= PLA[4];PLB[7]= PLA[7];	D2b();
            PLB[3]= PLA[5];PLB[4]= PLA[7];PLB[5]= PLA[3];PLB[6]= PLA[4];PLB[7]= PLA[6];	D2b();
            PLB[3]= PLA[6];PLB[4]= PLA[7];PLB[5]= PLA[3];PLB[6]= PLA[4];PLB[7]= PLA[5];	D2b();
}
function D2b(){
                PLB[8]= PLB[3]+ PLB[4];o2 = " + " ;         	D3();
                PLB[8]= PLB[3]- PLB[4];o2 = " - "; 
        if (PLB[8] >0) {										D3();
        	}else{ 
        		PLB[8]= PLB[4]- PLB[3];							D3();
        }		
        if(PLB[3]== 1  || PLB[4]== 1) {k =1
        	}else{          
                PLB[8]= PLB[3]* PLB[4];o2 = " * " ;          	D3();
                PLB[8]= PLB[3]/ PLB[4];o2 = " / " ;
              		if(Math.ceil(PLB[8]) == PLB[8])        		D3();
                PLB[8]= PLB[4]/ PLB[3];
              		if(Math.ceil(PLB[8]) == PLB[8])        		D3();
		}
}
/* --------------------------------------- 3ème opération sur 4 --------------------------------------- */

function D3(){

	operation = 3;

            PLC[5]= PLB[5];PLC[6]= PLB[6];PLC[7]= PLB[7];PLC[8]= PLB[8];	D3b();
            PLC[5]= PLB[5];PLC[6]= PLB[7];PLC[7]= PLB[6];PLC[8]= PLB[8];	D3b();
            PLC[5]= PLB[5];PLC[6]= PLB[8];PLC[7]= PLB[6];PLC[8]= PLB[7];	D3b();
            PLC[5]= PLB[6];PLC[6]= PLB[7];PLC[7]= PLB[5];PLC[8]= PLB[8];	D3b();
            PLC[5]= PLB[6];PLC[6]= PLB[8];PLC[7]= PLB[5];PLC[8]= PLB[7];	D3b();
            PLC[5]= PLB[7];PLC[6]= PLB[8];PLC[7]= PLB[5];PLC[8]= PLB[6];	D3b();
}
function D3b(){
                PLC[9]= PLC[5]+ PLC[6];o3 = " + " ;            	D4();
                PLC[9]= PLC[5]- PLC[6];o3 = " - " ;
        if(PLC[9]> 0){											D4();
        }else{   
        		PLC[9]= PLC[6]- PLC[5];							D4();
        }
        if(PLC[5]== 1 || PLC[6]== 1) { k =1
        }else{          
                PLC[9]= PLC[5] * PLC[6];o3 = " * "  ;           D4();
                PLC[9]= PLC[5] / PLC[6];o3 = " / " 
		      			 if(Math.ceil(PLC[9]) == PLC[9])        D4();
                PLC[9]= PLC[6] / PLC[5]; 
		      			 if(Math.ceil(PLC[9]) == PLC[9])        D4();
		}
}
/* --------------------------------------- 4ème opération sur 4 ------------------------- */
function D4(){

			if (PLC[9] == sol){solution()};
            PLD[7]= PLC[7];PLD[8]= PLC[8];PLD[9]= PLC[9];		D4b();
            PLD[7]= PLC[7];PLD[8]= PLC[9];PLD[9]= PLC[8];		D4b();
            PLD[7]= PLC[8];PLD[8]= PLC[9];PLD[9]= PLC[7];		D4b();
}
       		
function D4b(){
	if(essai == 4){
		operation = 4
				PLD[10]= PLD[7]+ PLD[8];o4 = " + "  	;if(PLD[10]== sol) {solution()};     		 
		      	PLD[10]= PLD[7]- PLD[8];o4 = " - "  	;if(PLD[10]== sol) {solution()};
		  		PLD[10]= PLD[8]- PLD[7]  			  	;if(PLD[10]== sol) {solution()};
		  		
		if (PLD[7] == 1 || PLD[8] == 1){  k =1
        }else{           
		      	PLD[10]= PLD[7]* PLD[8];o4 = " * "  	;if(PLD[10]== sol) {solution()};
		      	PLD[10]= PLD[7]/ PLD[8];o4 = " / " 		;if(PLD[10]== sol) {solution()};
		      	PLD[10]= PLD[8]/ PLD[7]					;if(PLD[10]== sol) {solution()};
    		 
		}
	}
	
/* ---------------------------------------          fin   4 opérations -------------------- */
/* ---------------------------------------          suite 5 opérations -------------------- */		

	if(essai == 5){
		operation = 4

				PLD[10]= PLD[7]+ PLD[8];o4 = " + "  ; 	E1()		         		 
		      	PLD[10]= PLD[7]- PLD[8];o4 = " - "  ; 
		if (PLD[10] > 0) {								E1()
		}else{ 
		  		PLD[10]= PLD[8]- PLD[7]; 				E1()
		}	      	
		if (PLD[7] == 1 || PLD[8] == 1){  k =1
        }else{           
		      	PLD[10]= PLD[7]* PLD[8];o4 = " * "  ;	E1()
		      	PLD[10]= PLD[7]/ PLD[8];o4 = " / " 
		      		 if(Math.ceil(PLD[10]) == PLD[10])	E1()
		      	PLD[10]= PLD[8]/ PLD[7]; 
		      		 if(Math.ceil(PLD[10]) == PLD[10])	E1()    		 
		}
	}
}

function E1(){
		operation = 5
		
			    nn++
        PLE[9]= PLD[9];PLE[10]= PLD[10]

                PLE[11]= PLE[9]+ PLE[10];o5 = " + ";	if(PLE[11]== sol) {solution()};
                PLE[11]= PLE[9]- PLE[10];o5 = " - ";	if(PLE[11]== sol) {solution()};
                PLE[11]= PLE[10]- PLE[9];o5 = " - ";	if(PLE[11]== sol) {solution()};
                PLE[11]= PLE[9]* PLE[10];o5 = " * ";	if(PLE[11]== sol) {solution()};
                PLE[11]= PLE[9]/ PLE[10];o5 = " / ";	if(PLE[11]== sol) {solution()};
                PLE[11]= PLE[10]/ PLE[9];o5 = " / ";	if(PLE[11]== sol) {solution()};
                         		                   		                	               		
}


function solution(){
			
	if(trouve == 0){	
					trouve = 1; result = ""
					longueur_solution = operation
					alaligne = String.fromCharCode(13)
					result=alaligne +"Le compte est bon  : " + alaligne	 + alaligne			
					if(PLA[1] >= PLA[2]) result=result + PLA[1] + o1 + PLA[2] + " = " + PLA[7]+ alaligne
					if(PLA[1] < PLA[2]) result=result + PLA[2] + o1 + PLA[1] + " = " + PLA[7]+ alaligne
			if(operation >1) {
					if(PLB[3] >= PLB[4]) result=result + PLB[3] + o2 + PLB[4] + " = " + PLB[8]+ alaligne
					if(PLB[3] < PLB[4]) result=result + PLB[4] + o2 + PLB[3] + " = " + PLB[8]+ alaligne
			}
			if(operation >2) {					
					if(PLC[5] >= PLC[6]) result=result + PLC[5] + o3 + PLC[6] + " = " + PLC[9]+ alaligne
					if(PLC[5] < PLC[6]) result=result + PLC[6] + o3 + PLC[5] + " = " + PLC[9]+ alaligne
			}
			if(operation >3) {		
					if(PLD[7] >= PLD[8]) result=result + PLD[7] + o4 + PLD[8] + " = " + PLD[10]+ alaligne
					if(PLD[7] < PLD[8]) result=result + PLD[8] + o4 + PLD[7] + " = " + PLD[10]+ alaligne
			}
			if(operation >4) {						
					if(PLE[9] >= PLE[10]) result=result + PLE[9] + o5 + PLE[10] + " = " + PLE[11]
					if(PLE[9] < PLE[10]) result=result + PLE[10] + o5 + PLE[9] + " = " + PLE[11]
			}				
			duree = Math.ceil((t2-t1)*100)/100
			document.COMPTE.solu.focus()
	}
					
}
function chrono_long() {
	now = new Date(); 
	nowtime =now.getTime()

	time_dif=(nowtime-entertime)/1000;
	time_dif=Math.round(time_dif);
	duree = time_dif
	document.getElementById("lechrono").value = duree
}

