Automatic dictionary generation - Python
<p>I am trying to create a program which outputs all permutations of a string of length <em>n</em> whilst avoiding a defined substring, of length <em>k</em>. For example:</p>

<p>Derive all possible strings, up to a length of 5 characters, that can be generated from an initial empty set, which can either go to A or B, but the string cannot contain the substring "AAB" which is not allowed.</p>

<p>i.e. base case of <code>[""]</code> is the empty set.
The dictionary would be - <code>A:{A}, B:{A,B}</code></p>

<p>From the empty set we can go to A, and we can go to B. We can not go to a B after an A but we can go to an A after a B. And both A and B can access themselves </p>

<p>example output: a,b,aa,bb,ba,aaa,bbb,baa,bba ... etc</p>

<p>How would I go about prompting a user to define a substring to avoid, and from that generate a dictionary which abides to these rules?</p>

<p>Any help or clarification would be greatly received.</p>

<p>Regards,
rkhad</p>
