Python sudoku programming
        Posted  
        
            by trevor
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by trevor
        
        
        
        Published on 2009-11-19T18:31:29Z
        Indexed on 
            2010/03/31
            2:53 UTC
        
        
        Read the original article
        Hit count: 556
        
I need your help on this. I have this program and I must finish it. It's missing 3 parts.
Here is the program I'm working with:
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
# HERE ARE THE PARTS THAT REQUIRE HELP!!!!
def get_neighbors(x,y):
    return []
def update(A, i, j, value):
    return []
def solve(A):
    return []
# ENDS PARTS THAT REQUIRE HELP!!!!          
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)
I need to solve the stuff formerly in bold letters, now explicitly marked in the code, specifically
- get_neighbors():
- update():
- solve():
Thank you for your time and help.
© Stack Overflow or respective owner