Const $SIZE = 9, $REGION = Sqrt($SIZE) Const $LENGTH = $SIZE * $SIZE Global $aGrid[$SIZE][$SIZE] Global $aFinalGrid, $SolutionFound = False Global $Nx=" 7 6 1 5 98 6 6 34 8 3 17 2 6 6 28 19 5 8 79" Global $Nx=" 2 5 3 1 3 8 2 2 7 5 9 6 1 4 6 1 7 1 2 7 4 1 6 8 " Global $Nx=" 4 7 73 923 1 1 527 8 6 468 1 2 156 84 5 3 " Global $Nx=" 4187 5 3 694 2 6 4 42 87 7 3 7 351 9 2 7463" Global $N=StringSplit($Nx,"",2) Global $aart[9][9] local $pointera=0 local $pointerb=0 for $pointera= 1 to 9 for $pointerb= 1 to 9 if " "<>$N[($pointera-1)*9+$pointerb] Then $aart[$pointera-1][$pointerb-1]=$N[($pointera-1)*9+$pointerb] next next for $pointera= 1 to 9 for $pointerb= 1 to 9 If $aart[$pointerb-1][$pointera-1]>0 Then ConsoleWrite($aart[$pointerb-1][$pointera-1]&" ") Else consoleWrite(" ") EndIf next ConsoleWrite(@CRLF) next Solution($aart, 1) for $pointera= 1 to 9 for $pointerb= 1 to 9 ConsoleWrite($aFinalGrid[$pointerb-1][$pointera-1]&" ") next ConsoleWrite(@CRLF) next Func Solution($aTemp, $iLoc) ;_ArrayDisplay($aTemp) If $SolutionFound Then Return If $iLoc > $LENGTH Then $SolutionFound = True $aFinalGrid = $aTemp Return EndIf Local $iLine = Int(($iLoc - 1) / $SIZE) Local $iCol = Mod($iLoc - 1, $SIZE) If $aTemp[$iLine][$iCol] Then Solution($aTemp, $iLoc + 1) Else For $i = 1 To $SIZE If Possible($aTemp, $iLine, $iCol, $i) Then $aTemp[$iLine][$iCol] = $i Solution($aTemp, $iLoc + 1) EndIf Next EndIf EndFunc ;==>Solution Func Possible(ByRef $aGrid, $iLine, $iCol, $iValue) For $i = 0 To $SIZE - 1 If $aGrid[$iLine][$i] = $iValue Then Return False If $aGrid[$i][$iCol] = $iValue Then Return False Next Local $iRegLine = Int($iLine / $REGION) * $REGION Local $iRegCol = Int($iCol / $REGION) * $REGION For $line = $iRegLine To $iRegLine + $REGION - 1 For $col = $iRegCol To $iRegCol + $REGION - 1 If $aGrid[$line][$col] = $iValue Then Return False Next Next Return True EndFunc ;==>Possible