python - Arrange strings for maximum overlap -
let's have set of strings:
strings = {'qqq', 'eqq', 'qqw', 'www', 'qww', 'wwe', 'eee', 'eeq', 'wee', 'qwe'}
how write algorithm arranges strings such overlap maximally? know 1 way of arranging them follows:
qww www wwe wee eee eeq eqq qqq qqw qwe
however, found above result brute-force solution. there cleverer way of doing this?
this called shortest superstring problem , np complete.
you might interested in approaches in paper approximation algorithms shortest common superstring problem jonathan turner.
Comments
Post a Comment