Suppose you have several substrings, e.g.,
AEBCA
DEA
BDAEBAE
EDEBAE
AED
How would you create a minimal-length string that contains the substrings in order?
The context, real or contrived (don't know), was this: Suppose you have several trucks, each of which must be loaded with items in a specific order. The substrings are the loads for each truck, and the letters are the items.
The trucks load by queuing in front of a line of bins, with each bin having only items of like type. The trucks can move forward only. In what order should the bins be arranged to have the minimum number?
My solution (http://www.excelforum.com/excel-programming-vba-macros/1086058-counting-letters-in-strings.html) was to catenate the substrings (24 characters in this example), and then strike every letter that left the substrings ascending in the reduced string. That gave me the 11-character string below, and the substrings are repeated below it:
AEBDAEBAECA
AEB CA
D E A
BDAEBAE
E D EBAE
AE D
Is this an instance of a more general problem that I could research by name? Can anyone suggest a less naive algorithm that might generate a better result?
Thank you.
You're looking for the shortest common supersequence (scs). According to Wikipedia,