Problem: I would like to know the number of elements in the cartesian power $X^n$ (cartesian product of one set $X$ by itself, $n$ times) with a majority constraint: how many elements in $X^n$ have a (relative) majority of one element of the set (say $x\in X$)?
On top of that, I'd like to fix one element in the cartesian power to a certain value (say the second), and count the number of possibilities with this fixed value.
Simple example: with $X=\{A, B, C\}$ and $n=4$. The question is: how many four-letter words with an $A$ in the second position have a (relative) majority of $A$'s? And how many have a (relative) majority of $B$'s?
Solution for the simple example: We can iterate on the total number $k$ of the element we want as a (relative) majority (say $A$).
- With $k=4$ elements being $A$, there is 1 option ($A$ is the majority, and $A$ is in the second position)
$AAAA$
- With $k=3$ elements being $A$, there are three possibilities for locating $A$'s. The second element is $A$ by constraint. The two extra $A$'s can be in position $(1,3), (1,4)$ or $(3,4)$. And there is one free position, where it can be everything but $A$: 2 possibilities. In total: $3\times 2=6$ possibilities.
$AAAB, AAAC, AABA, AACA, BAAA, CAAA$
- With $k=2$ elements being $A$'s, there is an extra-challenge: the two remaining positions should not be the same, otherwise $A$'s are not a majority anymore. About locating the $A$'s, one is fixed in the second position and the other $A$ can be in position $(1)$, $(3)$ or $(4)$: 3 possibilities. In the two remaining positions, there are 2 possibilities for the first one ($B$ or $C$ but not $A$) and 1 possibility for the second one (not $A$ and not the same than the first one). Total: 6 possibilities.
$AABC, AACB, BAAC, CAAB, BACA, CABA$
- With $k=1$ element being $A$, there are zero possibilities for $A$ to be a majority (three remaining possibilities, with only two letters, $B$ and $C$, so necessarily a majority of $B$ or $C$).
So with $n=4$ and 3 elements in the original set, there are 13 possibilities.
General solution? Is there a closed form formula to compute this number?
Same problem, expressed in a network formulation: In a network with 3 rows ($\{A, B, C\}$) and $n=4$ columns, assuming paths from left to right (e.g., using node $A_1$, then $B_2$, then $A_3$ and finally $C_3$), the question becomes: how many paths are going through node $A_2$ and have a (relative) majority of $A$ nodes?
Same problem, expressed in a voting context: Calculate winning outcomes of plurality voting