qazwsx Posted August 25, 2007 Share Posted August 25, 2007 I am having trouble with a func in my sudoku solver. Here is a description of wat it should do: Sometimes a candidate within a row or column is restricted to one box. Since one of these cells must contain that specific candidate, the candidate can safely be excluded from the remaining cells in the box. In the example on the right, the left column has candidate 9's only in the middle box. Therefore, since one of these cells must be a 9 (otherwise the column would be without a 9), 9's can safely be excluded from all cells in this middle box except those in the left column. CODE Global $possibilities[10][10][10] ;[row][column][number] 1 = applicable 0 or "" = not Func _lockedcandidatecolumn($column) Local $row[3] For $d = 1 To 9 ;number For $l = 1 To 9 ;row If $possibilities[$l][$column][$d] = 1 Then Select ;gets rows of three candidates Case $row[1] <> "" $row[2] = $l MsgBox (0, $row[1], $row[2]) If $row[2] - $row[1] < 3 Then ;if in the same cell $cellpos_row = Floor($row[1] / 3) ; If $row= 0, 1, 2 then this=0, if $row= 3,4,5 then this=1, if $row= 6,7,8 then this=2 $cellpos_col = Floor(($column - 1) / 3) ; If $column= 1,2,3 then this=0, etc.. For $z = 3 * $cellpos_row To 3 * $cellpos_row + 2 ; (0 to 2) or (3 to 5) or (6 to 8) ;row For $x = 3 * $cellpos_col + 1 To 3 * $cellpos_col + 3 ; (1 to 3) or (4 to 6) or (7 to 9) ;column If $x <> $column Then $possibilities[$z][$x][$d] = 0 Next Next EndIf $row[1] = "" $row[2] = "" Case $row[1] = "" $row[1] = $l EndSelect EndIf Next Next $row[1] = "" $row[2] = "" EndFunc ;==>_lockedcandidatecolumn Im getting an error the $possibilites range is being exceded here "If $x <> $column Then $possibilities[$z][$x][$d] = 0" the odd this is that same syntax has worked for all the other funcs in my script. If you need more of the script jsut ask. Link to comment Share on other sites More sharing options...
martin Posted August 25, 2007 Share Posted August 25, 2007 I am having trouble with a func in my sudoku solver. Here is a description of wat it should do: CODE Global $possibilities[10][10][10] ;[row][column][number] 1 = applicable 0 or "" = not Func _lockedcandidatecolumn($column) Local $row[3] For $d = 1 To 9 ;number For $l = 1 To 9 ;row If $possibilities[$l][$column][$d] = 1 Then Select ;gets rows of three candidates Case $row[1] <> "" $row[2] = $l MsgBox (0, $row[1], $row[2]) If $row[2] - $row[1] < 3 Then ;if in the same cell $cellpos_row = Floor($row[1] / 3) ; If $row= 0, 1, 2 then this=0, if $row= 3,4,5 then this=1, if $row= 6,7,8 then this=2 $cellpos_col = Floor(($column - 1) / 3) ; If $column= 1,2,3 then this=0, etc.. For $z = 3 * $cellpos_row To 3 * $cellpos_row + 2 ; (0 to 2) or (3 to 5) or (6 to 8) ;row For $x = 3 * $cellpos_col + 1 To 3 * $cellpos_col + 3 ; (1 to 3) or (4 to 6) or (7 to 9) ;column If $x <> $column Then $possibilities[$z][$x][$d] = 0 Next Next EndIf $row[1] = "" $row[2] = "" Case $row[1] = "" $row[1] = $l EndSelect EndIf Next Next $row[1] = "" $row[2] = "" EndFunc ;==>_lockedcandidatecolumn Im getting an error the $possibilites range is being exceded here "If $x <> $column Then $possibilities[$z][$x][$d] = 0" the odd this is that same syntax has worked for all the other funcs in my script. If you need more of the script jsut ask. My best guess is that you should have $row[2] = $l -1 and $row[1] = $l - 1 Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now