<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> class Solution : <EOL> def solveSudoku ( self , board ) : <EOL> """<STR_LIT>""" <EOL> for row in xrange ( len ( board ) ) : <EOL> board [ row ] = list ( board [ row ] ) <EOL> self . solve ( board , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> for row in xrange ( len ( board ) ) : <EOL> board [ row ] = "<STR_LIT>" . join ( board [ row ] ) <EOL> def solve_TLE ( self , board ) : <EOL> """<STR_LIT>""" <EOL> n = len ( board ) <EOL> if all ( [ board [ i / n ] [ i % n ] != "<STR_LIT:.>" for i in xrange ( n * n ) ] ) : <EOL> return True <EOL> for i in xrange ( n ) : <EOL> for j in xrange ( n ) : <EOL> if board [ i ] [ j ] == "<STR_LIT:.>" : <EOL> for num in range ( <NUM_LIT:1> , <NUM_LIT:10> ) : <EOL> num_str = str ( num ) <EOL> condition_row = all ( [ board [ i ] [ col ] != num_str for col in xrange ( n ) ] ) <EOL> condition_col = all ( [ board [ row ] [ j ] != num_str for row in xrange ( n ) ] ) <EOL> condition_square = all ( [ board [ i / <NUM_LIT:3> * <NUM_LIT:3> + count / <NUM_LIT:3> ] [ j / <NUM_LIT:3> * <NUM_LIT:3> + count % <NUM_LIT:3> ] != num_str for count in xrange ( n ) ] ) <EOL> if condition_col and condition_row and condition_square : <EOL> board [ i ] [ j ] = num_str <EOL> if not self . solve ( board ) : <EOL> board [ i ] [ j ] = "<STR_LIT:.>" <EOL> else : <EOL> return True <EOL> return False <EOL> def solve ( self , board , i , j ) : <EOL> """<STR_LIT>""" <EOL> if j >= <NUM_LIT:9> : <EOL> return self . solve ( board , i + <NUM_LIT:1> , <NUM_LIT:0> ) <EOL> if i == <NUM_LIT:9> : <EOL> return True <EOL> if board [ i ] [ j ] == "<STR_LIT:.>" : <EOL> for num in range ( <NUM_LIT:1> , <NUM_LIT:10> ) : <EOL> num_str = str ( num ) <EOL> if all ( [ board [ i ] [ col ] != num_str for col in xrange ( <NUM_LIT:9> ) ] ) and all ( [ board [ row ] [ j ] != num_str for row in xrange ( <NUM_LIT:9> ) ] ) and all ( [ board [ i / <NUM_LIT:3> * <NUM_LIT:3> + count / <NUM_LIT:3> ] [ j / <NUM_LIT:3> * <NUM_LIT:3> + count % <NUM_LIT:3> ] != num_str for count in xrange ( <NUM_LIT:9> ) ] ) : <EOL> board [ i ] [ j ] = num_str <EOL> if not self . solve ( board , i , j + <NUM_LIT:1> ) : <EOL> board [ i ] [ j ] = "<STR_LIT:.>" <EOL> else : <EOL> return True <EOL> else : <EOL> return self . solve ( board , i , j + <NUM_LIT:1> ) <EOL> return False <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> Solution ( ) . solveSudoku ( <EOL> [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ] <EOL> ) </s>
