Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Suggested approach</h2> <p>I would recommend you read up on a <a href="http://en.wikipedia.org/wiki/Deterministic_finite_automaton" rel="nofollow">deterministic finite automaton</a>.</p> <p>The way I would attempt to model this kind of problem is to turn the problem into a state machine that is able to recognise strings of the type that you want based on feeding characters in one at a time.</p> <p>Once you have a state machine, you can use dynamic programming to count the number of matching strings that can be generated by starting in a particular state. (The state incorporates knowing how many characters have been generated so far, and the progress in each of your rules.)</p> <p>With the results of this dynamic programming, you can generate the k^th lexicographically ordered example of a matching string in time O(n) where n is the length of the string.</p> <p>However, the cost of solving the dynamic programming will vary a lot depending on the complexity of your rule set.</p> <h2>Example</h2> <p>For your example 3:</p> <pre><code>There must be at least 2 differences from the original string The differences must be in the alphabet set (A,B,C,D,E) Differences must occur within defined index ranges of the string Each range must have 2 differences </code></pre> <p>the state would need to include the following information:</p> <pre><code>Number of differences in first range (0,1,2) Number of differences in second range (0,1,2) </code></pre> <p>so there would be a total of 9 states to model.</p> <p>For a system with R ranges, each requiring D differences, there would be (D+1)^R states required (fewer if the ranges do not overlap).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload