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

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -