File size: 319 Bytes
887f6b2
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
def best_overlap(a, b):
    return max([(score(a[offset:], b), offset) for offset in range(len(a))], key=lambda x: x[0])[1]

def score(a, b):
    return sum([a[i] == b[i] for i in range(len(a))])

a = 'abcde'
b = 'abbde'

print(best_overlap(a, b))
print(a + '-' * best_overlap(a, b))
print('-' * best_overlap(a, b) + b)