Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
2.3 kB
3
Indexable
Never
def solve3():
    global Matrix
    row, col = findNextEmpty3()
    if row is None:
        print("LLLLLLLLLLLLLLLLLLLL")
        return True
    if (row and col) > 5 and (row and col) < 9:
        for n in range(1, 10):
            if checkNumberCenter(col, row, n):
                print("AAAAAAAAAA")
                threadLock.acquire()
                Matrix[row][col] = n
                threadLock.release()
                if solve3():
                    return True
            threadLock.acquire()
            Matrix[row][col] = 0
            threadLock.release()
        return False
    elif row > 5 and row < 9 and col > 11 and col < 15:
        for n in range(1, 10):
            if checkNumberCenter(col, row, n):
                print("BBBBBBBBBB")
                threadLock.acquire()
                Matrix[row][col] = n
                threadLock.release()
                if solve3():
                    return True
            threadLock.acquire()
            Matrix[row][col] = 0
            threadLock.release()
        return False
    elif row > 11 and row < 15 and col > 5 and col < 9:
        for n in range(1, 10):
            if checkNumberCenter(col, row, n):
                print("CCCCCCCCCC")
                threadLock.acquire()
                Matrix[row][col] = n
                threadLock.release()
                if solve3():
                    return True
            threadLock.acquire()
            Matrix[row][col] = 0
            threadLock.release()
        return False
    elif row > 11 and row < 15 and col > 11 and col < 15:
        for n in range(1, 10):
            if checkNumberCenter(col, row, n):
                print("DDDDDDDD")
                threadLock.acquire()
                Matrix[row][col] = n
                threadLock.release()
                if solve3():
                    return True
            threadLock.acquire()
            Matrix[row][col] = 0
            threadLock.release()
        return False
    else:
        for n in range(1, 10):
            if checkNumberCenter(col, row, n):
                print("XXXXXXXXXXXX")
                Matrix[row][col] = n
                if solve3():
                    return True
            Matrix[row][col] = 0
        return False