def solve_TLE(self, board):
        """

        :param board: a 9x9 2D array
        :return: Boolean
        """
        n = len(board)
        if all([board[i/n][i%n]!="." for i in xrange(n*n)]):
            return True

        for i in xrange(n):
            for j in xrange(n):
                if board[i][j]==".":
                    for num in range(1, 10):
                        num_str = str(num)
                        # row
                        condition_row = all([board[i][col]!=num_str for col in xrange(n)])
                        # col
                        condition_col = all([board[row][j]!=num_str for row in xrange(n)])
                        # square
                        condition_square = all([board[i/3*3+count/3][j/3*3+count%3]!=num_str for count in xrange(n)])

                        if condition_col and condition_row and condition_square:
                            board[i][j] = num_str
                            if not self.solve(board):
                                board[i][j] = "."
                            else:
                                return True

        return False
dataset/ETHPy150Open algorhythms/LeetCode/036 Sudoku Solver.py/Solution.solve_TLE/original