Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
2.0 kB
2
Indexable
Never
    # down-right sudoku
    if(x > 8 and y > 11):
        if y < 15 and x > 14:
            for i in range(12, 21):
                #print(Matrix[y][i])
                if Matrix[y][i] == n:
                    return False
            for i in range(15, 21):

                #print(Matrix[i][x])
                if Matrix[i][x-3] == n:
                    return False
            for i in range(12, 15):

                #print(Matrix[i][x])
                if Matrix[i][x] == n:
                    return False

            x0 = (x//3)*3
            y0 = (y//3)*3

            for i in range(0, 3):
                for j in range(0, 3):
                    #  print(board[y0+i][x0+j])
                    if Matrix[y0+i][x0+j] == n:
                        return False
            return True
            # joint square
        elif (x > 11 and x < 15 and y < 15):
            for i in range(6, 21):

                if Matrix[y][i] == n:
                    return False

            for i in range(6, 21):
                if (Matrix[i][x]) == n:
                    return False

            x0 = (x//3)*3
            y0 = (y//3)*3
            for i in range(0, 3):
                for j in range(0, 3):
                    #  print(board[y0+i][x0+j])
                    if Matrix[y0+i][x0+j] == n:
                        return False
            return True
        else:
            for i in range(9, 18):
                #print(Matrix[y][i])
                if Matrix[y][i] == n:
                    return False
            for i in range(12, 21):
                #print(Matrix[i][x])
                if Matrix[i][x] == n:
                    return False

            x0 = (x//3)*3
            y0 = (y//3)*3

            for i in range(0, 3):
                for j in range(0, 3):
                    #  print(board[y0+i][x0+j])
                    if Matrix[y0+i][x0+j] == n:
                        return False
            return True