Your ruleset is basically right, except it's a set, not a string, and order does not matter. I sorted it and made it into a string for convenience because perl regex operate on strings, and there is a substring function, but not a subset function. I repeat back what you wrote with updated wording:
I want to run through the set and select four characters from it. After I've taken those four out, I want to go back and get four more from what's left, and so on, until I can't form any more tuples. The rules for selecting 4-tuples are that they must all be the same letter (quantity of at least 4), or they must be one letter from each of four consecutive letters.
I have tried your program, and it does only very little. I do not understand that big regex. I will explain what is missing. For the first data line, the remainder after taking out the same-tuples is ADEFFGMMSSTV. It should be split this way: ADEF;FGMS;MSTV. For the second data line, after taking out the same-tuples the remainder is ADEFFGGMMSTV. From this, no solution can be found anymore, as no matter how you turn it, there are only at most two 4-tuples left that satisfy the second condition and the last 4 are not consecutive. For the third data line, the program says nothing, it correctly recognises this set has no solution, but shouldn't it at least try to remove the obvious 4-tuples ADEF or DEFG?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|