automate sudoku boards

This commit is contained in:
2025-09-24 15:35:52 +02:00
parent 018a56f172
commit 4451ef60e1
4 changed files with 89 additions and 82 deletions

View File

@@ -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: