hi, i have to make a simple sudoku solver, i am done 3/4 of it but i'm having a little trouble on somethings, here is what i've got so far
import copy
def display(A):
if A:
for i in range(9):
for j in range(9):
if type(A[i][j]) == type([]): print A[i][j][0],
else: print A[i][j],
print
print
else: print A
def has_conflict(A):
for i in range(9):
for j in range(9):
for (x,y) in get_neighbors(i,j):
if len(A[i][j])==1 and A[i][j]==A[x][y]: return True
return False
def get_neighbors(x,y): # no idea how to get it or do it
return []
def update(A, i, j, value): # no idea how to do it
return []
def solve(A): # not sure if it's coorect
return []
A = []
infile = open('puzzle1.txt', 'r')
for i in range(9):
A += [[]]
for j in range(9):
num = int(infile.read(2))
if num: A[i] += [[num]]
else: A[i] += [[1,2,3,4,5,6,7,8,9]]
for i in range(9):
for j in range(9):
if len(A[i][j])==1: A = update(A, i,j, A[i][j][0])
if A==[]: break
if A==[]: break
if A<>[]: A = solve(A)
display(A)
so as you can see i did everything except for the def update, and get neighbour. I've tried many times before i post it but just couldn't do it. So if anybody can help me that would be great, also this is due on monday. any help THX