utility function to search complete string from any given index of 2d array
def internalSearch ( ii , needle , row , col , hay , row_max , col_max ) : NEW_LINE INDENT found = 0 NEW_LINE if ( row >= 0 and row <= row_max and col >= 0 and col <= col_max and needle [ ii ] == hay [ row ] [ col ] ) : NEW_LINE INDENT match = needle [ ii ] NEW_LINE ii += 1 NEW_LINE hay [ row ] [ col ] = 0 NEW_LINE if ( ii == len ( needle ) ) : NEW_LINE INDENT found = 1 NEW_LINE DEDENT else : NEW_LINE DEDENT DEDENT