Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Sudoku/Zkl/sudoku-1.zkl
Normal file
22
Task/Sudoku/Zkl/sudoku-1.zkl
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
fcn trycell(sdku,pos=0){
|
||||
row,col:=pos/9, pos%9;
|
||||
|
||||
if(pos==81) return(True);
|
||||
if(sdku[pos]) return(trycell(sdku, pos + 1));
|
||||
|
||||
used:=0;
|
||||
foreach r in (9){ used=used.bitOr((1).shiftLeft(sdku[r*9 + col] - 1)) }
|
||||
foreach c in (9){ used=used.bitOr((1).shiftLeft(sdku[row*9 + c] - 1)) }
|
||||
|
||||
row,col = row/3*3, col/3*3;
|
||||
foreach r,c in ([row..row+2], [col..col+2])
|
||||
{ used=used.bitOr((1).shiftLeft(sdku[r*9 + c] - 1)) }
|
||||
|
||||
sdku[pos]=1; while(sdku[pos]<=9){
|
||||
if(used.isEven and trycell(sdku, pos + 1)) return(True);
|
||||
sdku[pos]+=1; used/=2;
|
||||
}
|
||||
|
||||
sdku[pos]=0;
|
||||
return(False);
|
||||
}
|
||||
19
Task/Sudoku/Zkl/sudoku-2.zkl
Normal file
19
Task/Sudoku/Zkl/sudoku-2.zkl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
problem:=
|
||||
#<<<
|
||||
" 5 3 0 0 7 0 0 0 0
|
||||
6 0 0 1 9 5 0 0 0
|
||||
0 9 8 0 0 0 0 6 0
|
||||
8 0 0 0 6 0 0 0 3
|
||||
4 0 0 8 0 3 0 0 1
|
||||
7 0 0 0 2 0 0 0 6
|
||||
0 6 0 0 0 0 2 8 0
|
||||
0 0 0 4 1 9 0 0 5
|
||||
0 0 0 0 8 0 0 7 9";
|
||||
#<<<
|
||||
s:=problem.split().apply("toInt").copy(); // writable list of 81 ints
|
||||
trycell(s).println();
|
||||
println("+-----+-----+-----+");
|
||||
foreach n in (3){
|
||||
s[n*27,27].pump(Console.println,T(Void.Read,8),("| " + "%s%s%s | "*3).fmt); // 3 lines
|
||||
println("+-----+-----+-----+");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue