This is a successor to a previous challenge.
Input
An integer \$1 \leq n \leq 5\$.
Task
Your code should produce all strings that satisfy the following properties:
- Your string should contain exactly two each of the first \$n\$ letters of the alphabet.
- It should not contain the same letter twice in a row
- It must start with the letter
a
. - If there is a letter at index
i
in the string, all the letters earlier in the alphabet must occur somewhere at the indices1..i-1
. This means, for example, that the firstc
can't come before the firstb
. - It must contain exactly \$2n\$ zeros.
- For each zero there must exist a pair of identical letters so that one of the pair is somewhere to its left and one of the pair is somewhere to its right in the string.
- It must not contain anything other than zeros and the lower case letters.
Examples
n=1,`a00a` is the only valid output.
n=2,`a0ab000b`and `ab0000ab` are both valid outputs. `a0bab000` and `a0a0b00b` are not valid.
n=3,`a0bc0b0a000c` and `a0b000ca0b0c` are both valid outputs. ` a0cb0b0a000c` and `a0b000ba0c0c` are not valid.
a00ab00b
a valid output for n=2? \$\endgroup\$1, 28, 1816, 180143, 23783809
. \$\endgroup\$