var x=new Array();
var rank=new Array();
var delta=new Array();
function sample(){
tx=0;
for(s=1;s<10;s++){
for(sx=1;sx<10;sx++){
tx=tx+1;
x[tx]=s;
}
}
shuffle();
for(s=1;s<82;s++){
delta[s]=0;
}
for(s=1;s<9;s++){
sx=rank[s];
delta[sx]=1;
}
for(s=9;s<17;s++){
sx=rank[s];
delta[sx]=2;
}
for(s=17;s<25;s++){
sx=rank[s];
delta[sx]=3;
}
for(s=25;s<33;s++){
sx=rank[s];
delta[sx]=4;
}
mode=4;
number=32;
number=number+1;
mode=mode+1;
if(mode>4)mode=1;
sx=rank[number];
delta[sx]=mode;
pon();
paint();
}
function paint(){
var sub=new svgpaint();
var a=new Array();
var b=new Array();
var c=new Array();
var d=new Array();
sx=0;
for(s=1;s<82;s++){
if(delta[s]==1)sx=sx+1;
if(delta[s]==1)a[sx]=s;
}
sx=0;
for(s=1;s<82;s++){
if(delta[s]==2)sx=sx+1;
if(delta[s]==2)b[sx]=s;
}
sx=0;
for(s=1;s<82;s++){
if(delta[s]==3)sx=sx+1;
if(delta[s]==3)c[sx]=s;
}
sx=0;
for(s=1;s<82;s++){
if(delta[s]==4)sx=sx+1;
if(delta[s]==4)d[sx]=s;
}
str="<svg width=\"500\" height=\"500\">";
for(s=1;s<9;s++){
s1=a[s];
if(x[s1]==1)str=str+sub.rect(50*s,50,50,50,"red");
if(x[s1]==2)str=str+sub.rect(50*s,50,50,50,"blue");
if(x[s1]==3)str=str+sub.rect(50*s,50,50,50,"green");
if(x[s1]==4)str=str+sub.rect(50*s,50,50,50,"yellow");
if(x[s1]==5)str=str+sub.rect(50*s,50,50,50,"red");
if(x[s1]==6)str=str+sub.rect(50*s,50,50,50,"blue");
if(x[s1]==7)str=str+sub.rect(50*s,50,50,50,"green");
if(x[s1]==8)str=str+sub.rect(50*s,50,50,50,"yellow");
if(x[s1]==9)str=str+sub.rect(50*s,50,50,50,"red");
}
for(s=1;s<9;s++){
s1=b[s];
if(x[s1]==1)str=str+sub.rect(50*s,100,50,50,"red");
if(x[s1]==2)str=str+sub.rect(50*s,100,50,50,"blue");
if(x[s1]==3)str=str+sub.rect(50*s,100,50,50,"green");
if(x[s1]==4)str=str+sub.rect(50*s,100,50,50,"yellow");
if(x[s1]==5)str=str+sub.rect(50*s,100,50,50,"red");
if(x[s1]==6)str=str+sub.rect(50*s,100,50,50,"blue");
if(x[s1]==7)str=str+sub.rect(50*s,100,50,50,"green");
if(x[s1]==8)str=str+sub.rect(50*s,100,50,50,"yellow");
if(x[s1]==9)str=str+sub.rect(50*s,100,50,50,"red");
}
for(s=1;s<9;s++){
s1=c[s];
if(x[s1]==1)str=str+sub.rect(50*s,150,50,50,"red");
if(x[s1]==2)str=str+sub.rect(50*s,150,50,50,"blue");
if(x[s1]==3)str=str+sub.rect(50*s,150,50,50,"green");
if(x[s1]==4)str=str+sub.rect(50*s,150,50,50,"yellow");
if(x[s1]==5)str=str+sub.rect(50*s,150,50,50,"red");
if(x[s1]==6)str=str+sub.rect(50*s,150,50,50,"blue");
if(x[s1]==7)str=str+sub.rect(50*s,150,50,50,"green");
if(x[s1]==8)str=str+sub.rect(50*s,150,50,50,"yellow");
if(x[s1]==9)str=str+sub.rect(50*s,150,50,50,"red");
}
for(s=1;s<9;s++){
s1=d[s];
if(x[s1]==1)str=str+sub.rect(50*s,250,50,50,"red");
if(x[s1]==2)str=str+sub.rect(50*s,250,50,50,"blue");
if(x[s1]==3)str=str+sub.rect(50*s,250,50,50,"green");
if(x[s1]==4)str=str+sub.rect(50*s,250,50,50,"yellow");
if(x[s1]==5)str=str+sub.rect(50*s,250,50,50,"red");
if(x[s1]==6)str=str+sub.rect(50*s,250,50,50,"blue");
if(x[s1]==7)str=str+sub.rect(50*s,250,50,50,"green");
if(x[s1]==8)str=str+sub.rect(50*s,250,50,50,"yellow");
if(x[s1]==9)str=str+sub.rect(50*s,250,50,50,"red");
}
str=str+"</svg>";
$("#memo").html(str);
}
function pon(){
var a=new Array();
sx=0;
for(s=1;s<82;s++){
if(delta[s]==mode)sx=sx+1;
if(delta[s]==mode)a[sx]=s;
}
n1=9*Math.random();
n2=Math.floor(n1)+1;
sx=a[n2];
delta[sx]=0;
}
function shuffle(){
var point=new Array();
var ch=new Array();
for(s=1;s<82;s++){
point[s]=100*Math.random();
ch[s]=0;
}
for(r=1;r<82;r++){
sx=0;
maxu=-9999;
for(s=1;s<82;s++){
h=0;
if(point[s]>maxu)h=h+1;
if(ch[s]<50)h=h+1;
if(h==2)maxu=point[s];
if(h==2)sx=s;
}
rank[r]=sx;
ch[sx]=100;
}
}
最終更新:2015年12月31日 17:04