Hi,
I'm following this youtube code for a sudoku solver using python.
In the following piece
Could someone explain the 2 I don't understand. I understand from the context that it's connected to checking a 3 by 3 square, but I can't find an explanation for this code.
Thanks
I'm following this youtube code for a sudoku solver using python.
In the following piece
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
def possible(y,x,n): global grid for i in range ( 0 , 9 ): if grid[y][i] = = n: return False for i in range ( 0 , 9 ): if grid[i][x] = = n: return False """ [b]don't understand the following 2 lines[/b] """ x0 = (x / / 3 ) * 3 y0 = (y / / 3 ) * 3 for i in range ( 0 , 3 ): for j in range ( 0 , 3 ): if grid[y0 + i][x0 + j] = = n : return False return True |
Thanks