Take a closer look at the actual original strings. The second two strings match
multiple substrings, so the desired output actually shows this, but in a sort-of-confusing way.
Take this example:
STRING
-------
GCGCTCGACGC
SUBSTRINGS
----------
GCGC ACG == [GCGC]TC[ACG]C
But, when we have OVERLAPPING sequences the output should 'mash-up' a bit:
STRING
-------
GCGCTCGACGC
SUBSTRINGS
----------
GCGC GCTC == [GCGCTC]GACGC
Do you see how GC
GC AND
GCTC MERGE into one
single substring for the desired output?
So I think the algorithm should look like this:
Make as many straight matches as you can
If your match is within a string that has already been matched, modify that match to include the new match
Can you imagine how messy this would look if you had 100 substrings and a main string running 10,000 letters long (which I assume is possible because this stuff looks like gene sequence data)?
Celebrate Intellectual Diversity
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.