#include #include #include #Include #Include #include #include #include ;GUI GuiCreate("SudokuResolver", 600, 320) ; Images ;GuiCtrlCreatePic("sudoku_600x320.jpg",0,0, 600, 320) ;GuiCtrlSetColor(-1,0xffffff) ;Ont créer les 81 cases $Case1Bloc1 = GuiCtrlCreateInput("",20, 20, 20, 20) $Case2Bloc1 = GuiCtrlCreateInput("",50, 20, 20, 20) $Case3Bloc1 = GuiCtrlCreateInput("",80, 20, 20, 20) $Case4Bloc1 = GuiCtrlCreateInput("",20, 50, 20, 20) $Case5Bloc1 = GuiCtrlCreateInput("",50, 50, 20, 20) $Case6Bloc1 = GuiCtrlCreateInput("",80, 50, 20, 20) $Case7Bloc1 = GuiCtrlCreateInput("",20, 80, 20, 20) $Case8Bloc1 = GuiCtrlCreateInput("",50, 80, 20, 20) $Case9Bloc1 = GuiCtrlCreateInput("",80, 80, 20, 20) $Case1Bloc2 = GuiCtrlCreateInput("",120, 20, 20, 20) $Case2Bloc2 = GuiCtrlCreateInput("",150, 20, 20, 20) $Case3Bloc2 = GuiCtrlCreateInput("",180, 20, 20, 20) $Case4Bloc2 = GuiCtrlCreateInput("",120, 50, 20, 20) $Case5Bloc2 = GuiCtrlCreateInput("",150, 50, 20, 20) $Case6Bloc2 = GuiCtrlCreateInput("",180, 50, 20, 20) $Case7Bloc2 = GuiCtrlCreateInput("",120, 80, 20, 20) $Case8Bloc2 = GuiCtrlCreateInput("",150, 80, 20, 20) $Case9Bloc2 = GuiCtrlCreateInput("",180, 80, 20, 20) $Case1Bloc3 = GuiCtrlCreateInput("",220, 20, 20, 20) $Case2Bloc3 = GuiCtrlCreateInput("",250, 20, 20, 20) $Case3Bloc3 = GuiCtrlCreateInput("",280, 20, 20, 20) $Case4Bloc3 = GuiCtrlCreateInput("",220, 50, 20, 20) $Case5Bloc3 = GuiCtrlCreateInput("",250, 50, 20, 20) $Case6Bloc3 = GuiCtrlCreateInput("",280, 50, 20, 20) $Case7Bloc3 = GuiCtrlCreateInput("",220, 80, 20, 20) $Case8Bloc3 = GuiCtrlCreateInput("",250, 80, 20, 20) $Case9Bloc3 = GuiCtrlCreateInput("",280, 80, 20, 20) $Case1Bloc4 = GuiCtrlCreateInput("",20, 120, 20, 20) $Case2Bloc4 = GuiCtrlCreateInput("",50, 120, 20, 20) $Case3Bloc4 = GuiCtrlCreateInput("",80, 120, 20, 20) $Case4Bloc4 = GuiCtrlCreateInput("",20, 150, 20, 20) $Case5Bloc4 = GuiCtrlCreateInput("",50, 150, 20, 20) $Case6Bloc4 = GuiCtrlCreateInput("",80, 150, 20, 20) $Case7Bloc4 = GuiCtrlCreateInput("",20, 180, 20, 20) $Case8Bloc4 = GuiCtrlCreateInput("",50, 180, 20, 20) $Case9Bloc4 = GuiCtrlCreateInput("",80, 180, 20, 20) $Case1Bloc5 = GuiCtrlCreateInput("",120, 120, 20, 20) $Case2Bloc5 = GuiCtrlCreateInput("",150, 120, 20, 20) $Case3Bloc5 = GuiCtrlCreateInput("",180, 120, 20, 20) $Case4Bloc5 = GuiCtrlCreateInput("",120, 150, 20, 20) $Case5Bloc5 = GuiCtrlCreateInput("",150, 150, 20, 20) $Case6Bloc5 = GuiCtrlCreateInput("",180, 150, 20, 20) $Case7Bloc5 = GuiCtrlCreateInput("",120, 180, 20, 20) $Case8Bloc5 = GuiCtrlCreateInput("",150, 180, 20, 20) $Case9Bloc5 = GuiCtrlCreateInput("",180, 180, 20, 20) $Case1Bloc6 = GuiCtrlCreateInput("",220, 120, 20, 20) $Case2Bloc6 = GuiCtrlCreateInput("",250, 120, 20, 20) $Case3Bloc6 = GuiCtrlCreateInput("",280, 120, 20, 20) $Case4Bloc6 = GuiCtrlCreateInput("",220, 150, 20, 20) $Case5Bloc6 = GuiCtrlCreateInput("",250, 150, 20, 20) $Case6Bloc6 = GuiCtrlCreateInput("",280, 150, 20, 20) $Case7Bloc6 = GuiCtrlCreateInput("",220, 180, 20, 20) $Case8Bloc6 = GuiCtrlCreateInput("",250, 180, 20, 20) $Case9Bloc6 = GuiCtrlCreateInput("",280, 180, 20, 20) $Case1Bloc7 = GuiCtrlCreateInput("",20, 220, 20, 20) $Case2Bloc7 = GuiCtrlCreateInput("",50, 220, 20, 20) $Case3Bloc7 = GuiCtrlCreateInput("",80, 220, 20, 20) $Case4Bloc7 = GuiCtrlCreateInput("",20, 250, 20, 20) $Case5Bloc7 = GuiCtrlCreateInput("",50, 250, 20, 20) $Case6Bloc7 = GuiCtrlCreateInput("",80, 250, 20, 20) $Case7Bloc7 = GuiCtrlCreateInput("",20, 280, 20, 20) $Case8Bloc7 = GuiCtrlCreateInput("",50, 280, 20, 20) $Case9Bloc7 = GuiCtrlCreateInput("",80, 280, 20, 20) $Case1Bloc8 = GuiCtrlCreateInput("",120, 220, 20, 20) $Case2Bloc8 = GuiCtrlCreateInput("",150, 220, 20, 20) $Case3Bloc8 = GuiCtrlCreateInput("",180, 220, 20, 20) $Case4Bloc8 = GuiCtrlCreateInput("",120, 250, 20, 20) $Case5Bloc8 = GuiCtrlCreateInput("",150, 250, 20, 20) $Case6Bloc8 = GuiCtrlCreateInput("",180, 250, 20, 20) $Case7Bloc8 = GuiCtrlCreateInput("",120, 280, 20, 20) $Case8Bloc8 = GuiCtrlCreateInput("",150, 280, 20, 20) $Case9Bloc8 = GuiCtrlCreateInput("",180, 280, 20, 20) $Case1Bloc9 = GuiCtrlCreateInput("",220, 220, 20, 20) $Case2Bloc9 = GuiCtrlCreateInput("",250, 220, 20, 20) $Case3Bloc9 = GuiCtrlCreateInput("",280, 220, 20, 20) $Case4Bloc9 = GuiCtrlCreateInput("",220, 250, 20, 20) $Case5Bloc9 = GuiCtrlCreateInput("",250, 250, 20, 20) $Case6Bloc9 = GuiCtrlCreateInput("",280, 250, 20, 20) $Case7Bloc9 = GuiCtrlCreateInput("",220, 280, 20, 20) $Case8Bloc9 = GuiCtrlCreateInput("",250, 280, 20, 20) $Case9Bloc9 = GuiCtrlCreateInput("",280, 280, 20, 20) ;Boutons $Resoudre = GuiCtrlCreateButton("Résoudre", 480, 260, 100, 40) $Quitter = GuiCtrlCreateButton("Quitter", 320, 260, 100, 40) $Reset = GuiCtrlCreateButton("Reset", 320, 100, 260, 20) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Quitter Exit Case $Reset For $Bloc = 1 to 9 For $Case = 1 to 9 $QuelCase = Eval("Case" & $Case & "Bloc" & $Bloc) GUICtrlSetData($QuelCase,"") Next Next ;############################################################################################################################################################################################### ;##################################################################### Création tableau CheckBloc(1) ########################################################################################### ;############################################################################################################################################################################################### case $Resoudre While 1 Dim $Tableau[10][10][8][10] For $Bloc = 1 to 9 Step +1 For $Case = 1 to 9 step +1 For $CaseB =1 to 9 step +1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $Bloc) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][1][$CaseB] = $LireCaseBloc Next ;# _ArraySearch ne fonctionnant qu'en tableau unidimensionel Dim $ParadeArraySearch[10] For $1 = 1 to 9 $ParadeArraySearch[$1] = $Tableau[$Bloc][$Case][1][$1] Next ;############################################################################################################################################################################################# ;# Placement des 1 à l'emplacement et ainsi de suite Dim $Find1, $Find2, $Find3, $Find4, $Find5, $Find6, $Find7, $Find8, $Find9 For $i = 1 to 9 $Search1 = _ArraySearch($ParadeArraySearch, 1, 0, 0, 0, False) $Search2 = _ArraySearch($ParadeArraySearch, 2, 0, 0, 0, False) $Search3 = _ArraySearch($ParadeArraySearch, 3, 0, 0, 0, False) $Search4 = _ArraySearch($ParadeArraySearch, 4, 0, 0, 0, False) $Search5 = _ArraySearch($ParadeArraySearch, 5, 0, 0, 0, False) $Search6 = _ArraySearch($ParadeArraySearch, 6, 0, 0, 0, False) $Search7 = _ArraySearch($ParadeArraySearch, 7, 0, 0, 0, False) $Search8 = _ArraySearch($ParadeArraySearch, 8, 0, 0, 0, False) $Search9 = _ArraySearch($ParadeArraySearch, 9, 0, 0, 0, False) Next For $i = 1 to 9 $Tableau[$Bloc][$Case][1][$i] = "" $Search = Eval("Search" & $i) $Find = Eval("Find" & $i) if $Search > 0 then $Find += 1 If $Find = 1 then $Tableau[$Bloc][$Case][1][$i] = $i EndIf Next ;############################################################################################################################################################################################## $VariableALire = Eval("Case" & $Case & "Bloc" & $Bloc) While 1 ;############################################################################################################################################################################################## ;####################################################################### Création tableau NombresPossibleBloc(2) ############################################################################## ;############################################################################################################################################################################################## $LireCaseBloc = GUICtrlRead($VariableALire, 1) if not $LireCaseBloc = 0 then Exitloop elseIf @error = -1 Then ExitLoop Else For $i = 1 to 8 if $Tableau[$Bloc][$Case][1][$i] = $i Then $Tableau[$Bloc][$Case][2][$i] = "" Else $Tableau[$Bloc][$Case][2][$i] = $i Endif Next if $Tableau[$Bloc][$Case][1][9] = 9 Then $Tableau[$Bloc][$Case][2][9] = "" ExitLoop Else $Tableau[$Bloc][$Case][2][9] = 9 ExitLoop EndIf Endif Wend Next Next ;############################################################################################################################################################################################### ;############################################################################## Horizontal case 1 à 3 ########################################################################################## ;############################################################################################################################################################################################### ; Bloc 1 à 3 For $Bloc = 1 to 3 Step +1 For $Case = 1 to 3 Step +1 dim $emplacement = 0 For $BlocB = 1 to 3 Step +1 For $CaseB = 1 to 3 Step +1 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][3][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesHorizontal() ;############################################################################################################################################################################################## _NombresPossibleHorizontal() Next Next ;############################################################################################################################################################################################# ; Bloc 4 à 6 For $Bloc = 4 to 6 Step +1 For $Case = 1 to 3 Step +1 dim $emplacement = 0 For $BlocB = 4 to 6 Step +1 For $CaseB = 1 to 3 Step +1 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][3][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesHorizontal() ;############################################################################################################################################################################################## _NombresPossibleHorizontal() Next Next ;############################################################################################################################################################################################# ; Bloc 7 à 9 For $Bloc = 7 to 9 Step +1 For $Case = 1 to 3 Step +1 dim $emplacement = 0 For $BlocB = 7 to 9 Step +1 For $CaseB = 1 to 3 Step +1 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][3][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesHorizontal() ;############################################################################################################################################################################################## _NombresPossibleHorizontal() Next Next ;############################################################################################################################################################################################## ;########################################################################## horizontal case 4 à 6 ############################################################################################# ;############################################################################################################################################################################################## ; Bloc 1 à 3 For $Bloc = 1 to 3 Step +1 For $Case = 4 to 6 Step +1 dim $emplacement = 0 For $BlocB = 1 to 3 Step +1 For $CaseB = 4 to 6 Step +1 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][3][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesHorizontal() ;############################################################################################################################################################################################## _NombresPossibleHorizontal() Next Next ;############################################################################################################################################################################################## ; Bloc 4 à 6 For $Bloc = 4 to 6 Step +1 For $Case = 4 to 6 Step +1 dim $emplacement = 0 For $BlocB = 4 to 6 Step +1 For $CaseB = 4 to 6 Step +1 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][3][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesHorizontal() ;############################################################################################################################################################################################## _NombresPossibleHorizontal() Next Next ;############################################################################################################################################################################################## ; Bloc 7 à 9 For $Bloc = 7 to 9 Step +1 For $Case = 4 to 6 Step +1 dim $emplacement = 0 For $BlocB = 7 to 9 Step +1 For $CaseB = 4 to 6 Step +1 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][3][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesHorizontal() ;############################################################################################################################################################################################## _NombresPossibleHorizontal() Next Next ;############################################################################################################################################################################################## ;################################################################################## Horizontal Case 7 à 9 ##################################################################################### ;############################################################################################################################################################################################## ;Bloc 1 à 3 For $Bloc = 1 to 3 Step +1 For $Case = 7 to 9 Step +1 dim $emplacement = 0 For $BlocB = 1 to 3 Step +1 For $CaseB = 7 to 9 Step +1 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][3][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesHorizontal() ;############################################################################################################################################################################################## _NombresPossibleHorizontal() Next Next ;############################################################################################################################################################################################## ; Bloc 4 à 6 For $Bloc = 4 to 6 Step +1 For $Case = 7 to 9 Step +1 dim $emplacement = 0 For $BlocB = 4 to 6 Step +1 For $CaseB = 7 to 9 Step +1 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][3][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesHorizontal() ;############################################################################################################################################################################################## _NombresPossibleHorizontal() Next Next ;############################################################################################################################################################################################## ; Bloc 7 à 9 For $Bloc = 7 to 9 Step +1 For $Case = 7 to 9 Step +1 dim $emplacement = 0 For $BlocB = 7 to 9 Step +1 For $CaseB = 7 to 9 Step +1 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][3][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesHorizontal() ;############################################################################################################################################################################################## _NombresPossibleHorizontal() Next Next ;############################################################################################################################################################################################## ;#################################################################################### Vertical case 1,4,7 ##################################################################################### ;############################################################################################################################################################################################## ; Bloc 1, 4, 7 For $Bloc = 1 to 7 Step +3 For $Case = 1 to 7 Step +3 dim $emplacement = 0 For $BlocB = 1 to 7 Step +3 For $CaseB = 1 to 7 Step +3 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][5][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesVertical() ;############################################################################################################################################################################################## _NombresPossibleVertical() Next Next ;############################################################################################################################################################################################## ; Bloc 2, 5, 8 For $Bloc = 2 to 8 Step +3 For $Case = 1 to 7 Step +3 dim $emplacement = 0 For $BlocB = 2 to 8 Step +3 For $CaseB = 1 to 7 Step +3 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][5][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesVertical() ;############################################################################################################################################################################################## _NombresPossibleVertical() Next Next ;############################################################################################################################################################################################## ; Bloc 3, 6, 9 For $Bloc = 3 to 9 Step +3 For $Case = 1 to 7 Step +3 dim $emplacement = 0 For $BlocB = 3 to 9 Step +3 For $CaseB = 1 to 7 Step +3 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][5][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesVertical() ;############################################################################################################################################################################################## _NombresPossibleVertical() Next Next ;############################################################################################################################################################################################## ;############################################################################# Vertical case 2,5,8 ############################################################################################ ;############################################################################################################################################################################################## ; Bloc 1, 4, 7 For $Bloc = 1 to 7 Step +3 For $Case = 2 to 8 Step +3 dim $emplacement = 0 For $BlocB = 1 to 7 Step +3 For $CaseB = 2 to 8 Step +3 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][5][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesVertical() ;############################################################################################################################################################################################## _NombresPossibleVertical() Next Next ;############################################################################################################################################################################################## ; Bloc 2, 5, 8 For $Bloc = 2 to 8 Step +3 For $Case = 2 to 8 Step +3 dim $emplacement = 0 For $BlocB = 2 to 8 Step +3 For $CaseB = 2 to 8 Step +3 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][5][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesVertical() ;############################################################################################################################################################################################## _NombresPossibleVertical() Next Next ;############################################################################################################################################################################################## ; Bloc 3, 6, 9 For $Bloc = 3 to 9 Step +3 For $Case = 2 to 8 Step +3 dim $emplacement = 0 For $BlocB = 3 to 9 Step +3 For $CaseB = 2 to 8 Step +3 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][5][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesVertical() ;############################################################################################################################################################################################## _NombresPossibleVertical() Next Next ;############################################################################################################################################################################################## ;########################################################################### Vertical Case 3,6,9 ############################################################################################## ;############################################################################################################################################################################################## ; Bloc 1, 4, 7 For $Bloc = 1 to 7 Step +3 For $Case = 3 to 9 Step +3 dim $emplacement = 0 For $BlocB = 1 to 7 Step +3 For $CaseB = 3 to 9 Step +3 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][5][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesVertical() ;############################################################################################################################################################################################## _NombresPossibleVertical() Next Next ;############################################################################################################################################################################################## ; Bloc 2, 5, 8 For $Bloc = 2 to 8 Step +3 For $Case = 3 to 9 Step +3 dim $emplacement = 0 For $BlocB = 2 to 8 Step +3 For $CaseB = 3 to 9 Step +3 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][5][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesVertical() ;############################################################################################################################################################################################## _NombresPossibleVertical() Next Next ;############################################################################################################################################################################################## ; Bloc 3, 6, 9 For $Bloc = 3 to 9 Step +3 For $Case = 3 to 9 Step +3 dim $emplacement = 0 For $BlocB = 3 to 9 Step +3 For $CaseB = 3 to 9 Step +3 $emplacement += 1 $VariableALire = Eval("Case" & $CaseB & "Bloc" & $BlocB) $LireCaseBloc = GUICtrlRead($VariableALire, 1) $Tableau[$Bloc][$Case][5][$emplacement] = $LireCaseBloc Next Next _ChaqueChoseASaPlaceLignesVertical() ;############################################################################################################################################################################################## _NombresPossibleVertical() Next Next ;############################################################################################################################################################################################## ;######################################################################### Nombres Possible synthétisés ####################################################################################### ;############################################################################################################################################################################################## For $Bloc = 1 to 9 Step +1 For $Case =1 to 9 step +1 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 = 0 For $i = 1 to 9 $CaseA = Eval("Case" & $i) If $Tableau[$Bloc][$Case][2][$i] = $i Then $CaseA += 1 If $Tableau[$Bloc][$Case][4][$i] = $i Then $CaseA += 1 If $Tableau[$Bloc][$Case][6][$i] = $i Then $CaseA += 1 If $CaseA = 3 Then $Tableau[$Bloc][$Case][7][$i] = $i EndIf Next Next Next ;############################################################################################################################################################################################## ;######################################################################## Boucle Attribution possibilité unique ############################################################################### ;############################################################################################################################################################################################## For $Bloc = 1 to 9 Step +1 For $Case =1 to 9 step +1 Dim $UnePossibilite = 0 For $i = 1 to 9 step +1 If $Tableau[$Bloc][$Case][7][$i] = $i Then $UnePossibilite += 1 EndIf Next Dim $LeNombre = 0 If $UnePossibilite = 1 Then For $i = 1 to 9 step +1 $VariableALire = Eval("Case" & $Case & "Bloc" & $Bloc) If $Tableau[$Bloc][$Case][7][$i] > 0 Then $LeNombre = $Tableau[$Bloc][$Case][7][$i] GUICtrlSetData($VariableALire,$LeNombre) EndIf Next EndIf Next Next ;############################################################################################################################################################################################## ;####################################################################### Intrus Bloc ########################################################################################################## ;############################################################################################################################################################################################## Dim $Intrus[4][10][10] Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0 For $Bloc = 1 to 9 Step +1 For $Case =1 to 9 step +1 If $Tableau[$Bloc][$Case][7][1] = 1 Then $Case1 += 1 If $Tableau[$Bloc][$Case][7][2] = 2 Then $Case2 += 1 If $Tableau[$Bloc][$Case][7][3] = 3 Then $Case3 += 1 If $Tableau[$Bloc][$Case][7][4] = 4 Then $Case4 += 1 If $Tableau[$Bloc][$Case][7][5] = 5 Then $Case5 += 1 If $Tableau[$Bloc][$Case][7][6] = 6 Then $Case6 += 1 If $Tableau[$Bloc][$Case][7][7] = 7 Then $Case7 += 1 If $Tableau[$Bloc][$Case][7][8] = 8 Then $Case8 += 1 If $Tableau[$Bloc][$Case][7][9] = 9 Then $Case9 += 1 Next For $i = 1 to 9 $CaseA = Eval("Case" & $i) If $CaseA = 1 Then $Intrus[1][$Bloc][$i] = $i Endif Next Next For $Bloc = 1 to 9 Step +1 For $Case =1 to 9 step +1 $CaseBloc = Eval("Case" & $Case & "Bloc" & $Bloc) For $i = 1 to 9 step +1 If $Tableau[$Bloc][$Case][7][$i] > 0 Then If $Tableau[$Bloc][$Case][7][$i] = $Intrus[1][$Bloc][$i] Then GUICtrlSetData($CaseBloc,$Intrus[1][$Bloc][$i]) EndIf EndIf Next Next Next ;############################################################################################################################################################################################## ;##################################################################### Intrus Ligne Horizontal ################################################################################################ ;############################################################################################################################################################################################## ;Horizontal 1 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $H = 1 For $Bloc = 1 to 3 Step +1 For $Case =1 to 3 step +1 _ChercheIntrus() Next Next _EnregistrementIntrusHorizontal() For $Bloc = 1 to 3 Step +1 For $Case =1 to 3 step +1 _AttributionIntrusHorizontal() Next Next ;Horizontal 2 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $H = 2 For $Bloc = 1 to 3 Step +1 For $Case = 4 to 6 step +1 _ChercheIntrus() Next Next _EnregistrementIntrusHorizontal() For $Bloc = 1 to 3 Step +1 For $Case = 4 to 6 step +1 _AttributionIntrusHorizontal() Next Next ;Horizontal 3 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $H = 3 For $Bloc = 1 to 3 Step +1 For $Case = 7 to 9 step +1 _ChercheIntrus() Next Next _EnregistrementIntrusHorizontal() For $Bloc = 1 to 3 Step +1 For $Case = 7 to 9 step +1 _AttributionIntrusHorizontal() Next Next ;Horizontal 4 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $H = 4 For $Bloc = 4 to 6 Step +1 For $Case = 1 to 3 step +1 _ChercheIntrus() Next Next _EnregistrementIntrusHorizontal() For $Bloc = 4 to 6 Step +1 For $Case = 1 to 3 step +1 _AttributionIntrusHorizontal() Next Next ;Horizontal 5 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $H = 5 For $Bloc = 4 to 6 Step +1 For $Case = 4 to 6 step +1 _ChercheIntrus() Next Next _EnregistrementIntrusHorizontal() For $Bloc = 4 to 6 Step +1 For $Case = 4 to 6 step +1 _AttributionIntrusHorizontal() Next Next ;Horizontal 6 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $H = 6 For $Bloc = 4 to 6 Step +1 For $Case = 7 to 9 step +1 _ChercheIntrus() Next Next _EnregistrementIntrusHorizontal() For $Bloc = 4 to 6 Step +1 For $Case = 7 to 9 step +1 _AttributionIntrusHorizontal() Next Next ;Horizontal 7 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $H = 7 For $Bloc = 7 to 9 Step +1 For $Case = 1 to 3 step +1 _ChercheIntrus() Next Next _EnregistrementIntrusHorizontal() For $Bloc = 7 to 9 Step +1 For $Case = 1 to 3 step +1 _AttributionIntrusHorizontal() Next Next ;Horizontal 8 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $H = 8 For $Bloc = 7 to 9 Step +1 For $Case = 4 to 6 step +1 _ChercheIntrus() Next Next _EnregistrementIntrusHorizontal() For $Bloc = 7 to 9 Step +1 For $Case = 4 to 6 step +1 _AttributionIntrusHorizontal() Next Next ;Horizontal 9 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $H = 9 For $Bloc = 7 to 9 Step +1 For $Case = 7 to 9 step +1 _ChercheIntrus() Next Next _EnregistrementIntrusHorizontal() For $Bloc = 7 to 9 Step +1 For $Case = 7 to 9 step +1 _AttributionIntrusHorizontal() Next Next ;############################################################################################################################################################################################## ;############################################################# Intrus Lignes Verticals ######################################################################################################## ;############################################################################################################################################################################################## ;Vertical1 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $V = 1 For $Bloc = 1 to 7 Step +3 For $Case = 1 to 7 step +3 _ChercheIntrus() Next Next _EnregistrementIntrusVertical() For $Bloc = 1 to 7 Step +3 For $Case = 1 to 7 step +3 _AttributionIntrusVertical() Next Next ;Vertical2 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $V = 2 For $Bloc = 1 to 7 Step +3 For $Case = 2 to 8 step +3 _ChercheIntrus() Next Next _EnregistrementIntrusVertical() For $Bloc = 1 to 7 Step +3 For $Case = 2 to 8 step +3 _AttributionIntrusVertical() Next Next ;Vertical3 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $V = 3 For $Bloc = 1 to 7 Step +3 For $Case = 3 to 9 step +3 _ChercheIntrus() Next Next _EnregistrementIntrusVertical() For $Bloc = 1 to 7 Step +3 For $Case = 3 to 9 step +3 _AttributionIntrusVertical() Next Next ;Vertical4 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $V = 4 For $Bloc = 2 to 8 Step +3 For $Case = 1 to 7 step +3 _ChercheIntrus() Next Next _EnregistrementIntrusVertical() For $Bloc = 2 to 8 Step +3 For $Case = 1 to 7 step +3 _AttributionIntrusVertical() Next Next ;Vertical5 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $V = 5 For $Bloc = 2 to 8 Step +3 For $Case = 2 to 8 step +3 _ChercheIntrus() Next Next _EnregistrementIntrusVertical() For $Bloc = 2 to 8 Step +3 For $Case = 2 to 8 step +3 _AttributionIntrusVertical() Next Next ;Vertical6 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $V = 6 For $Bloc = 2 to 8 Step +3 For $Case = 3 to 9 step +3 _ChercheIntrus() Next Next _EnregistrementIntrusVertical() For $Bloc = 2 to 8 Step +3 For $Case = 3 to 9 step +3 _AttributionIntrusVertical() Next Next ;Vertical7 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $V = 7 For $Bloc = 3 to 9 Step +3 For $Case = 1 to 7 step +3 _ChercheIntrus() Next Next _EnregistrementIntrusVertical() For $Bloc = 3 to 9 Step +3 For $Case = 1 to 7 step +3 _AttributionIntrusVertical() Next Next ;Vertical8 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $V = 8 For $Bloc = 3 to 9 Step +3 For $Case = 2 to 8 step +3 _ChercheIntrus() Next Next _EnregistrementIntrusVertical() For $Bloc = 3 to 9 Step +3 For $Case = 2 to 8 step +3 _AttributionIntrusVertical() Next Next ;Vertical9 Dim $Case1 = 0, $Case2 = 0, $Case3 = 0, $Case4 = 0, $Case5 = 0, $Case6 = 0, $Case7 = 0, $Case8 = 0, $Case9 =0, $V = 9 For $Bloc = 3 to 9 Step +3 For $Case = 3 to 9 step +3 _ChercheIntrus() Next Next _EnregistrementIntrusVertical() For $Bloc = 3 to 9 Step +3 For $Case = 3 to 9 step +3 _AttributionIntrusVertical() Next Next ;############################################################################################################################################################################################## $OpenSortie = FileOpen("c:\Sortie.txt", 2) FileClose($OpenSortie) For $Bloc = 1 to 9 For $Case = 1 to 9 $OpenSortie = FileOpen("c:\Sortie.txt", 1) $VariableALire = Eval("Case" & $Case & "Bloc" & $Bloc) ;~ $Variable2 = Eval("LireCase" & $Case & "Bloc" & $Bloc) $Variable2 = GUICtrlRead($VariableALire) FileWriteLine($OpenSortie,$Variable2) FileClose($OpenSortie) Next Next $SizeSortie = FileGetSize("c:\Sortie.txt") If $SizeSortie = 243 Then ExitLoop Endif Wend EndSwitch Wend Func _ChaqueChoseASaPlaceLignesHorizontal() ;# _ArraySearch ne fonctionnant qu'en tableau unidimensionel Dim $ParadeArraySearch[10] = [0,0,0,0,0,0,0,0,0,0] For $1 = 1 to 9 $ParadeArraySearch[$1] = $Tableau[$Bloc][$Case][3][$1] Next ;# Placement des 1 à l'emplacement et ainsi de suite Dim $Find1 = 0, $Find2 = 0, $Find3 = 0, $Find4 = 0, $Find5 = 0, $Find6 = 0, $Find7 = 0, $Find8 = 0, $Find9 = 0 For $i = 1 to 9 $Search1 = _ArraySearch($ParadeArraySearch, 1, 0, 0, 0, False) $Search2 = _ArraySearch($ParadeArraySearch, 2, 0, 0, 0, False) $Search3 = _ArraySearch($ParadeArraySearch, 3, 0, 0, 0, False) $Search4 = _ArraySearch($ParadeArraySearch, 4, 0, 0, 0, False) $Search5 = _ArraySearch($ParadeArraySearch, 5, 0, 0, 0, False) $Search6 = _ArraySearch($ParadeArraySearch, 6, 0, 0, 0, False) $Search7 = _ArraySearch($ParadeArraySearch, 7, 0, 0, 0, False) $Search8 = _ArraySearch($ParadeArraySearch, 8, 0, 0, 0, False) $Search9 = _ArraySearch($ParadeArraySearch, 9, 0, 0, 0, False) Next For $i = 1 to 9 $Tableau[$Bloc][$Case][3][$i] = "" $Search = Eval("Search" & $i) $Find = Eval("Find" & $i) if $Search > 0 then $Find += 1 If $Find = 1 then $Tableau[$Bloc][$Case][3][$i] = $i EndIf Next EndFunc Func _ChaqueChoseASaPlaceLignesVertical() ;# _ArraySearch ne fonctionnant qu'en tableau unidimensionel Dim $ParadeArraySearch[10] = [0,0,0,0,0,0,0,0,0,0] For $1 = 1 to 9 $ParadeArraySearch[$1] = $Tableau[$Bloc][$Case][5][$1] Next ;# Placement des 1 à l'emplacement et ainsi de suite Dim $Find1 = 0, $Find2 = 0, $Find3 = 0, $Find4 = 0, $Find5 = 0, $Find6 = 0, $Find7 = 0, $Find8 = 0, $Find9 = 0 For $i = 1 to 9 $Search1 = _ArraySearch($ParadeArraySearch, 1, 0, 0, 0, False) $Search2 = _ArraySearch($ParadeArraySearch, 2, 0, 0, 0, False) $Search3 = _ArraySearch($ParadeArraySearch, 3, 0, 0, 0, False) $Search4 = _ArraySearch($ParadeArraySearch, 4, 0, 0, 0, False) $Search5 = _ArraySearch($ParadeArraySearch, 5, 0, 0, 0, False) $Search6 = _ArraySearch($ParadeArraySearch, 6, 0, 0, 0, False) $Search7 = _ArraySearch($ParadeArraySearch, 7, 0, 0, 0, False) $Search8 = _ArraySearch($ParadeArraySearch, 8, 0, 0, 0, False) $Search9 = _ArraySearch($ParadeArraySearch, 9, 0, 0, 0, False) Next For $i = 1 to 9 $Tableau[$Bloc][$Case][5][$i] = "" $Search = Eval("Search" & $i) $Find = Eval("Find" & $i) if $Search > 0 then $Find += 1 If $Find = 1 then $Tableau[$Bloc][$Case][5][$i] = $i EndIf Next EndFunc Func _NombresPossibleHorizontal() $VariableALire = Eval("Case" & $Case & "Bloc" & $Bloc) While 1 $LireCaseBloc = GUICtrlRead($VariableALire, 1) if not $LireCaseBloc = 0 then Exitloop elseIf @error = -1 Then ExitLoop Else For $i = 1 to 8 if $Tableau[$Bloc][$Case][3][$i] = $i Then $Tableau[$Bloc][$Case][4][$i] = "" Else $Tableau[$Bloc][$Case][4][$i] = $i Endif Next if $Tableau[$Bloc][$Case][3][9] = 9 Then $Tableau[$Bloc][$Case][4][9] = "" ExitLoop Else $Tableau[$Bloc][$Case][4][9] = 9 ExitLoop EndIf Endif Wend EndFunc Func _NombresPossibleVertical() $VariableALire = Eval("Case" & $Case & "Bloc" & $Bloc) While 1 $LireCaseBloc = GUICtrlRead($VariableALire, 1) if not $LireCaseBloc = 0 then Exitloop elseIf @error = -1 Then ExitLoop Else For $i = 1 to 8 if $Tableau[$Bloc][$Case][5][$i] = $i Then $Tableau[$Bloc][$Case][6][$i] = "" Else $Tableau[$Bloc][$Case][6][$i] = $i Endif Next if $Tableau[$Bloc][$Case][5][9] = 9 Then $Tableau[$Bloc][$Case][6][9] = "" ExitLoop Else $Tableau[$Bloc][$Case][6][9] = 9 ExitLoop EndIf Endif Wend EndFunc Func _ChercheIntrus() If $Tableau[$Bloc][$Case][7][1] = 1 Then $Case1 += 1 If $Tableau[$Bloc][$Case][7][2] = 2 Then $Case2 += 1 If $Tableau[$Bloc][$Case][7][3] = 3 Then $Case3 += 1 If $Tableau[$Bloc][$Case][7][4] = 4 Then $Case4 += 1 If $Tableau[$Bloc][$Case][7][5] = 5 Then $Case5 += 1 If $Tableau[$Bloc][$Case][7][6] = 6 Then $Case6 += 1 If $Tableau[$Bloc][$Case][7][7] = 7 Then $Case7 += 1 If $Tableau[$Bloc][$Case][7][8] = 8 Then $Case8 += 1 If $Tableau[$Bloc][$Case][7][9] = 9 Then $Case9 += 1 EndFunc Func _EnregistrementIntrusHorizontal() For $i = 1 to 9 $CaseA = Eval("Case" & $i) If $CaseA = 1 Then $Intrus[2][$H][$i] = $i Endif Next EndFunc Func _EnregistrementIntrusVertical() For $i = 1 to 9 $CaseA = Eval("Case" & $i) If $CaseA = 1 Then $Intrus[3][$V][$i] = $i Endif Next EndFunc Func _AttributionIntrusHorizontal() $CaseBloc = Eval("Case" & $Case & "Bloc" & $Bloc) For $i = 1 to 9 step +1 If $Tableau[$Bloc][$Case][7][$i] > 0 Then If $Tableau[$Bloc][$Case][7][$i] = $Intrus[2][$H][$i] Then GUICtrlSetData($CaseBloc,$Intrus[2][$H][$i]) EndIf Endif Next EndFunc Func _AttributionIntrusVertical() $CaseBloc = Eval("Case" & $Case & "Bloc" & $Bloc) For $i = 1 to 9 step +1 If $Tableau[$Bloc][$Case][7][$i] > 0 Then If $Tableau[$Bloc][$Case][7][$i] = $Intrus[3][$V][$i] Then GUICtrlSetData($CaseBloc,$Intrus[3][$V][$i]) EndIf EndIf Next EndFunc ;~