Words on a Subdivided Alphabet

69 Views Asked by At

Consider an alphabet of $N$ letters divided in $p$ families. The $i$-th family contains $n_i$ letters ($i=1,...,p$), and $\sum_{i=1}^p n_i = N$.

How many words of $q$ letters ($q \leq N$) use no letter more than once, and contain exactly $s$ pairs of adjacent letters from different families?