function indexRandom(lng){
var a = {},i,out=[],n=0;
while (n!=lng){
i = Math.floor(lng*Math.random());
if(typeof(a[i])=='undefined'){
a[i]=i; out.push(i);
n++;
}
}
return out;
}
var arr = [],ind = indexRandom(20),k;
for(i=0;i<20;i++) arr[i]=ind[i]%(k=i<10?20:3);
alert(arr)
alert(arr.join(''))