Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -1,13 +1,10 @@
|
|||
solve[array_] :=
|
||||
solve[sudoku_] :=
|
||||
NestWhile[
|
||||
Join @@ Function[newarray,
|
||||
Function[{i, j},
|
||||
Table[ReplacePart[newarray,
|
||||
Position[newarray, 0, {2}, 1][[1]] -> n], {n,
|
||||
Select[Range@9,
|
||||
FreeQ[newarray[[i]], #] && FreeQ[newarray[[All, j]], #] &&
|
||||
FreeQ[Partition[
|
||||
newarray, {3, 3}][[Sequence @@
|
||||
Quotient[{i, j}, 3, -2]]], #] &]}]] @@
|
||||
Position[newarray, 0, {2}, 1][[1]]] /@ # &, {array}, !
|
||||
FreeQ[#, 0] &]
|
||||
Join @@ Table[
|
||||
Table[ReplacePart[s, #1 -> n], {n, #2}] & @@
|
||||
First@SortBy[{#,
|
||||
Complement[Range@9, s[[First@#]], s[[;; , Last@#]],
|
||||
Catenate@
|
||||
Extract[Partition[s, {3, 3}], Quotient[#, 3, -2]]]} & /@
|
||||
Position[s, 0, {2}],
|
||||
Length@Last@# &], {s, #}] &, {sudoku}, ! FreeQ[#, 0] &]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue