Hey guys,
Im writing a sudoku game following this article:
http://norvig.com/sudoku.html
Im getting close, but Im having a problem with the "search" function.
Its:
Code:
def search(values):
"Using depth-first search and propagation, try all possible values."
if values is False:
return False ## Failed earlier
if all(len(values[s]) == 1 for s in squares):
return values ## Solved!
## Chose the unfilled square s with the fewest possibilities
_,s = min((len(values[s]), s) for s in squares if len(values[s]) > 1)
return some(search(assign(values.copy(), s, d))
for d in values[s])
Im trying to implement this in C but I dont get it :/ I see there is a recursive thing and the 2 ifs in the beginning check if the board is already sorted. But the last 3 lines. What do they do?
(I know its not the best place to ask this :/ )