def OverlapLength(left_string, right_string):
 left_string_length = len(left_string)
 right_string_length = len(right_string)
 if ((not left_string_length) or (not right_string_length)):
  return 0
 if (left_string_length > right_string_length):
  left_string = left_string[(- right_string_length):]
 elif (left_string_length < right_string_length):
  right_string = right_string[:left_string_length]
 if (left_string == right_string):
  return min(left_string_length, right_string_length)
 best = 0
 length = 1
 while True:
  pattern = left_string[(- length):]
  found = right_string.find(pattern)
  if (found < 0):
   return best
  length += found
  if (left_string[(- length):] == right_string[:length]):
   best = length
   length += 1

def OverlapLength ( left_string , right_string ) : left_string_length = len ( left_string ) right_string_length = len ( right_string ) if ( ( not left_string_length ) or ( not right_string_length ) ) : return 0 if ( left_string_length > right_string_length ) : left_string = left_string [ ( - right_string_length ) : ] elif ( left_string_length < right_string_length ) : right_string = right_string [ : left_string_length ] if ( left_string == right_string ) : return min ( left_string_length , right_string_length ) best = 0 length = 1 while True : pattern = left_string [ ( - length ) : ] found = right_string . find ( pattern ) if ( found < 0 ) : return best length += found if ( left_string [ ( - length ) : ] == right_string [ : length ] ) : best = length length += 1
returns the length of the overlap between two strings .