bit 演算版 lotos() 改定 ver.
Java6 上の jrunscript 用
function lotos(ltMd){ var l={ "ceil":0, "mask":[0,0], "bit":0, "lotoset":[], "col":0 }; function getLtCeil() {for(i=c=0; i<ltMd; c+= ++i); l.ceil=c*2+1;} function getLtBit(){ return(Math.ceil(Math.random()*l.ceil)); } function isAlreadyExist() { return 0!=(l.mask[Math.floor(l.bit/32)] & 1<<(l.bit%32)); } function setMaskBit() { l.mask[Math.floor(l.bit/32)] |= 1<<(l.bit%32); s= "00"+ l.bit; l.lotoset[l.col]=s.substr(s.length-2,2) } getLtCeil(); for(l.col=0,l.bit=getLtBit(),setMaskBit();l.col<ltMd;++l.col){ do{l.bit=getLtBit();} while(isAlreadyExist()); setMaskBit(); } return(l.lotoset.sort().toString()); } sx=read("5:minilot\n6:loto6\n"); if(sx<5 || sx>6){ print("bad arguments\n"); } else{ println(lotos(sx)); }