Hello, I have a problem while creating code. I have undertaken to convert a recursive function that can generate sudoku puzzles from PHP to VB. But, I am getting problem of the return type which is both an Integer and a boolean.
I do not know how to solve the solution. I am using the code below:
Code:
Private Function puzzle(Optional ByVal grid As Integer(,) = Nothing, Optional ByVal position As Integer = 0)
Sun i, j, v As Integer
Sun values = New List(Of Integer)
Sun result As Boolean
If (position = 81) Then
Return (grid)
End If
i = Math.Floor(position / 9)
j = position Mod 9
'list of numbers 1 to 9
values.AddRange({1, 2, 3, 4, 5, 6, 7, 8, 9})
'clears the values already used
If (v> 0) Then
For k As Integer = 0 To 8
'cut the value of the line
If (v = Int(grid(i, k))) Then
values.RemoveAt(v -- 1)
End If
'cut the value of the column
If (v = Int(grid(k, j))) Then
values.RemoveAt(v -- 1)
End If
'cut the value of the area
If (v = Int(grid(i + Math.Floor(k / 3)J + (k Mod 3)))) Then
values.RemoveAt(v -- 1)
End If
Next
End If
values = shuffleList(values)
For Each v In values
grid(i, j) = V
result = creer_grille(grid position + 1)
If (result) Then
Return result
End If
grid(i, j) = Nothing
Next
Return False
End Function
Thank you in advance for your help
Bookmarks