We arrange $N$ boys and $M$ girls in a row with importance of order (thus, we have $(N+M)!$ permutations for that arrangement). In how many ways can we get a maximal sequence of $K$ boys OR $K$ girls (or both)?
For example, here we have an arrangement of $N=4$ boys and $M=5$ girls with a maximal sequence of $K=3$ :
$$GGBGGBBBG$$ Of course we could have a sequence of 3 girls AND 3 boys in other row, that counts too.
EDIT: People told me that my interpretation for "maximal sequence" wasn't clear enough, so let me be more precise: I am looking for the Probability that there is at least one sequence of $K$ boys OR $K$ girls OR both - AND no sequence bigger than K. $$$$
I tried everything but (apparently) I always get duplications in my counting. I coded a python code which calculates exactly that, just for testing, and none of my trials worked (my answers was always bigger).
I'd really appreciate your help!
My attempt was: $\frac{{N\choose K}(N+M-K+1)!K!+{M\choose K}(N+M-K+1)!K!}{(N+M)!}$
where ${N\choose K}$ for choosing $K$ boys, $(N+M-K+1)!$ for putting everyone in line while relating the $K$ chosen-boys as one, then $K!$ for all of their permutations(the K-chosen-boys). Same thing for the girls. Devide all that with $(N+M)!$.
$$$$ We have 5 boys and 4 girls. There are $233280$ possibilities out of $362880$. $P(k=3) = 0.6428571428571429$
– ryden Jan 04 '22 at 09:52Please, can you show me what was your solution using the Principle of Inclusion Exclusion? – ryden Jan 04 '22 at 14:39