automate sudoku boards
This commit is contained in:
@@ -98,6 +98,7 @@ class CSP:
|
||||
"""
|
||||
|
||||
def backtrack(csp, assignment: dict[str, Any]) -> dict | None:
|
||||
print("i have been called")
|
||||
if len(assignment) == len(csp.variables):
|
||||
return assignment # base-case
|
||||
var = select_unassigned_variable(csp, assignment)
|
||||
@@ -108,6 +109,7 @@ class CSP:
|
||||
if result := backtrack(csp, assignment):
|
||||
return result
|
||||
assignment.pop(var)
|
||||
print("i have failed")
|
||||
return None # failure
|
||||
|
||||
def consistent(csp, var, value, assignment) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user