# Counting the number of strings starting with “t” and containing 2 vowels and 2 consonants

I generated a list of strings that match the criteria in the title as follows:

vowels = Characters @ "aeiou";
consonants = DeleteCases[Complement[Alphabet[], vowels], "t"];

v = Select[Tuples[vowels, {2}], Length @ Tally @ # != 1];
c = Select[Tuples[consonants, {2}], Length @ Tally @ # != 1];

Flatten[#, 2] & @
Table[
Permutations[Flatten[{v[[i]], c[[j]]}], {4}],
{i, Length @ v}, {j, Length @ c}
];

words = DeleteDuplicates["t" <> # & /@ %];
Length @ words
(* 45600 *)


The count agrees with my math; there are $$\binom52$$ ways of picking vowels, $$\binom{20}2$$ ways of picking (non-t) consonants, and $$4!$$ ways of arranging all but the first letter, hence $$4!\binom52\binom{20}2=45600$$ total words.

Is there a better way of generating all possible strings with the given criteria? I don't see a problem with my method, but think there is some corner-cutting that can be done.

For "counting the number of strings ..." you don't have to generate the list of such strings:

4! Binomial[Length @ vowels, 2] Binomial[Length @ consonants, 2]


45600

An alternative way to generate the list of words:

words = StringJoin["t", ##] & @@@ (Join @@ (Permutations /@ (Join @@@
Tuples[Subsets[#, {2}] & /@ {vowels, consonants}])));

Length @ words


45600

words // Short


{taebc, taecb, tabec, tabce, taceb, << 45591 >>, tzuoy, tzuyo, tzyou, tzyuo}

• Right, I was just trying to make an exercise in WL to confirm this count :) – user170231 Aug 27 at 20:46