python_data_scien/poc2/poc2_mini_proj_4.py
def solve_puzzle(self):
        """
        Generate a solution string for a puzzle
        Updates the puzzle and returns a move string
        """
        width = self.get_width()
        height =self.get_height()
        result_str = ''
        result_str += self.move_tile_to_end()

        
        if self.lower_row_invariant(height-1, width-1) == False: 
            #print 'phase1 start failed!'
            return
        #print 'phase1 start!'
        #print self
        for target_row in range(height-1, 1, -1):
            for target_col in range(width-1,-1,-1):
                    if target_col != 0 and self.lower_row_invariant(target_row, target_col):
                        result_str += self.solve_interior_tile(target_row, target_col)
                    elif self.lower_row_invariant(target_row, target_col):
                        #print 'solve_col0_tile:',target_row,target_col
                        #print self.lower_row_invariant(target_row, target_col)
                        result_str += self.solve_col0_tile(target_row)
                    #print self

        if self.row1_invariant(width-1) == False: 
            #print 'phase2 start failed!'
            return
        #print 'phase2 start!'
        #print self
        for target_col in range(width-1,1,-1):
            for target_row in [1,0]:
                if target_row == 1 and self.row1_invariant(target_col):
                    result_str += self.solve_row1_tile(target_col)
                elif self.row0_invariant(target_col):
                    result_str += self.solve_row0_tile(target_col)
                #print self

        if self.row1_invariant(1) == False: 
            #print 'phase3 start failed!'
            return
        #print 'phase3 start!'
        result_str += self.solve_2x2()
        #print 'phase3 end!!!'

        return result_str

        Generate a solution string for a puzzle
        Updates the puzzle and returns a move string
        
Generate a solution string for a puzzle
Updates the puzzle and returns a move string
Generate a solution string for a puzzle Updates the puzzle and returns a move string
def solve_puzzle(self):
        width = self.get_width()
        height =self.get_height()
        result_str = ''
        result_str += self.move_tile_to_end()
        if self.lower_row_invariant(height-1, width-1) == False: 
            return
        for target_row in range(height-1, 1, -1):
            for target_col in range(width-1,-1,-1):
                    if target_col != 0 and self.lower_row_invariant(target_row, target_col):
                        result_str += self.solve_interior_tile(target_row, target_col)
                    elif self.lower_row_invariant(target_row, target_col):
                        result_str += self.solve_col0_tile(target_row)
        if self.row1_invariant(width-1) == False: 
            return
        for target_col in range(width-1,1,-1):
            for target_row in [1,0]:
                if target_row == 1 and self.row1_invariant(target_col):
                    result_str += self.solve_row1_tile(target_col)
                elif self.row0_invariant(target_col):
                    result_str += self.solve_row0_tile(target_col)
        if self.row1_invariant(1) == False: 
            return
        result_str += self.solve_2x2()
        return result_str
def solve_puzzle ( self ) : width = self . get_width ( ) height = self . get_height ( ) result_str = '' result_str += self . move_tile_to_end ( ) if self . lower_row_invariant ( height - 1 , width - 1 ) == False : return for target_row in range ( height - 1 , 1 , - 1 ) : for target_col in range ( width - 1 , - 1 , - 1 ) : if target_col != 0 and self . lower_row_invariant ( target_row , target_col ) : result_str += self . solve_interior_tile ( target_row , target_col ) elif self . lower_row_invariant ( target_row , target_col ) : result_str += self . solve_col0_tile ( target_row ) if self . row1_invariant ( width - 1 ) == False : return for target_col in range ( width - 1 , 1 , - 1 ) : for target_row in [ 1 , 0 ] : if target_row == 1 and self . row1_invariant ( target_col ) : result_str += self . solve_row1_tile ( target_col ) elif self . row0_invariant ( target_col ) : result_str += self . solve_row0_tile ( target_col ) if self . row1_invariant ( 1 ) == False : return result_str += self . solve_2x2 ( ) return result_str
Generate a solution string for a puzzle
Updates the puzzle and returns a move string
Generate a solution string for a puzzle Updates the puzzle and returns a move string
"""
        Generate a solution string for a puzzle
        Updates the puzzle and returns a move string
        """ #print 'phase1 start failed!'
 #print 'phase1 start!'
 #print self
 #print 'solve_col0_tile:',target_row,target_col
 #print self.lower_row_invariant(target_row, target_col)
 #print self
 #print 'phase2 start failed!'
 #print 'phase2 start!'
 #print self
 #print self
 #print 'phase3 start failed!'
 #print 'phase3 start!'
 #print 'phase3 end!!!'

self