Assume I have an alphabet $\{A,B,C...\}$ with a total of $K$ symbols. For words of same length, I define the distance $d$ between them as the number of positions in which they have differing symbols (reduces to Hamming distance for $K=2$).
Starting from a fixed word $w$, I am interested in finding sets of words such that they 1) have distance $d$ to $w$, 2) have distance $D$ between each other.
How many of such sets are there, how big are they, and what would be a smart way to generate them?
Consider a solution attempt for $K=4$, $w_0=ABCDABCD$, $d=2$, and $D=4$.
One can choose $\displaystyle\binom{8}{2} =\dfrac{8!}{2!6!}=28$ combinations of the two letters to be alternated in $w_0$. For each of these two positions, we have $4-1=3$ options, which gives us the total of $28\times3\times3=252$ words $w_1$ of distance $2$ from $w_0$.
For each $w_1$ of these 252 words, there are $\displaystyle\binom{6}{2}\times3\times3 =135$ words $w_2$ which are distance 2 from $w_0$ and distance 4 from $w_1$. To find such words, we start from $w_0$ and alternate any two other letters except those two which we alternated to get $w_1$.
For each of the 135 words in the previous step, there are $\displaystyle\binom{4}{2}\times3\times3 =54$ of the words $w_3$ which are distance 4 from each other.
$\displaystyle\binom{2}{2}\times3\times3 =9$ options for $w_4$.
So it seems that one can find at most 4 words with the desired property, and there are $252\times135\times54\times9=16533720$ ways to do so.