Untitled

mail@pastecode.io avatar
unknown
python
3 years ago
1.2 kB
3
Indexable
def findNextEmpty5():
    global Matrix
    for r in range(12,15):
        for c in range(12, 21):
            if Matrix[r][c] == 0:
                return r, c
    for r in range(15, 21):
        for c in range(9, 18):
            if Matrix[r][c] == 0:
                return r, c
    return None, None




#down right sudoku
def solve5():
    global Matrix
    row, col = findNextEmpty5()
    if row is None:
        return True
    if row > 11 and row < 15 and col > 11 and col < 15:
        for n in range(1, 10):
            if checkNumber(col, row, n):
                print("XXXXXXXXXX")
                threadLock.acquire()
                Matrix[row][col] = n
                threadLock.release()
                if solve5():
                    return True
            threadLock.acquire()
            Matrix[row][col] = 0
            threadLock.release()
        return False
    else:
        for n in range(1, 10):
            if checkNumber(col, row, n):
                print("BBBBBBBBB")
                Matrix[row][col] = n
                if solve5():
                    return True
            Matrix[row][col] = 0
        return False