Demo entry 6751159

das

   

Submitted by anonymous on Jun 21, 2018 at 11:33
Language: JavaScript. Code size: 755 Bytes.

this.arr = [];
this.setThird(2,2);
this.setThird(5,5);
this.setThird(8,8);
var allNum = [1,2,3,4,5,6,7,8,9];
outerfor:
for(var i=1;i<=9;i++){
	innerfor:
	for(var j=1;j<=9;j++){
		if(this.arr[parseInt(i+''+j)]){
			continue innerfor;
		}
		var row = this.getRow(j,this.arr);
		var col = this.getCol(i,this.arr);
		var cell = this.getCell(i,j,this.arr);
		var arr = connect(connect(row,col),cell);
		var tempArr = arrMinus(allNum,arr);
			if(tempArr.length == 0){
				this.createarr();
				return;
				break outerfor;
			}
			var item;
					//如果生成的重复了就重新生成。
		do{
			item = tempArr[getRandom(tempArr.length)-1];
		}while(($.inArray(item, arr)>-1));

		this.arr[parseInt(i+''+j)] = item;
	}
}
this.backuparr = this.arr.slice();

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).