[JavaScript] 纯文本查看 复制代码
function Test_OutSide(){//自己也没算出来
var answer ;
var arr= [0,0,0,0,0, 0,0,0,0,0];
var t0= [ 0,1,2,3];
var t1= [ 2,3,0,1];
var t2= [ 2,5,1,3];
var t3= [ [0,4],[1,6],[0,8],[5,9]];
var t4= [ 7,3,8,6];
var t5= [ [1,3],[0,5],[2,9],[4,8]];
var t6= [2,1,0,3];
var t7= [6,4,1,9];
var t8= [5,9,1,8];
var t9 = [3,2,4,1];
for(arr[0]=0;arr[0]<4;arr[0]++){
for(arr[1]=0;arr[1]<4;arr[1]++){
for(arr[2]=0;arr[2]<4;arr[2]++){
for(arr[3]=0;arr[3]<4;arr[3]++){
for(arr[4]=0;arr[4]<4;arr[4]++){
for(arr[5]=0;arr[5]<4;arr[5]++){
for(arr[6]=0;arr[6]<4;arr[6]++){
for(arr[7]=0;arr[7]<4;arr[7]++){
for(arr[8]=0;arr[8]<4;arr[8]++){
for(arr[9]=0;arr[9]<4;arr[9]++){
answer = true;
var a=[0,0,0,0];
var b=[0,0,0,0];
for(var i=0;i<10;i++) {
a[arr[i]]++;
b[arr[i]]++;
}
a=this.Test_bubbleSort(a);
if(a[3]-a[0] != t9[arr[9]]) continue;
var boola= (arr[0]==arr[5]);
var boolb= (arr[t8[arr[8]]]==arr[4]);
if((boola&boolb) | (!(boola|boolb))) continue;
if(Math.abs(arr[0]-arr[t7[arr[7]]])==1) continue;
if(b[t6[arr[6]]]!=a[0] ) continue;
if(arr[7]!=arr[t5[arr[5]][0]] || arr[7]!=arr[t5[arr[5]][1]]) continue;
if(arr[4]!=arr[t4[arr[4]]]) continue;
if(arr[t3[arr[3]][0]] != arr[t3[arr[3]][1]]) continue;
var isContinue = false;
for (var i = 0 ; i <4; i++)
if(arr[t2[arr[2]]] == arr[t2[i]] && arr[2] != i) isContinue=true;
if(isContinue) continue;
if(arr[4] != t1[arr[1]]) continue;
}
}
}
}
}
}
}
}
}
}
}
function Test_bubbleSort( a){
var n= a.length;
for(var i =0 ; i< n-1; i++) {
for(var j = 0; j < n-i-1; j++) {
if(a[j] > a[j+1])
{
tmp = a[j] ; a[j] = a[j+1] ; a[j+1] = tmp;
}
}
}
return a;
}