salutations,
we are not sure on how to explain it, but,
suppose we have a string without spaces, which is a succession of words, for example: "cowboycatdog", and we looped through all the possible fragments of the words, checking its existence in an indexed dictionary. then, it returns an array with all the existing fragments of the string:
cow
cowboy
boy
cat
do
dog
notice that every word here exists. we already have the algorithm to do all that, but here is the doubt: how can we combine the items of the newly generated array in order to form the string "cowboycatdog" again? for example:
cow-boy-cat-dog
cowboy-cat-dog
would be the possible segmentations of this string, based on that array. the segmentation "cow-boy-cat-do-g", for example, wouldn't exist, because there is no word "g" in the array. (this is just a small example: the string and the fragments meaning anything could be much bigger).
does anyone have any idea on how to to this? thank you in advance.
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.