12 students participate in 3 competitions twice in total. Count possible results.

81 Views Asked by At

There are 12 students, who participate in 3 competitions.
Every student participate twice (in total, once in 2 competitions or twice in 1).
Count how many possible results of competitions exist - how many possible 3 ranking lists permutations exist.
We assume that there are no draws, so result of every competition is a ranking list (can be empty or contain repetitions).

I know how to this when every result of student is distinct - then it would be just $\binom{24 + 3 - 1}{3-1} * 24!$.
But in this case we must somehow subtract possibilities when we swap the same person.
Can you give me some clues?

Example:
For 2 students(John, Anne) possible ranking lists are:

1. |John|Anne|John|  - John participates in 1st and 3rd competition
   |Anne|    |    |  - Anne participates in 1st and 2nd competition

2. |Anne|Anne|John|  - John participates in 1st and 3rd competition
   |John|    |    |  - Anne participates in 1st and 2nd competition

3. |John|Anne|Anne|  - John participates in 1st competition twice
   |John|    |    |  - Anne participates in 2nd and 3rd competition

4. |John|    |Anne|  - John participates in 1st competition twice
   |John|    |Anne|  - Anne participates in 3rd competition twice
...


2

There are 2 best solutions below

1
On BEST ANSWER

Actually after a few days I found the answer (a closed formula).
It's a modification of the solution with distinct results.

Let's take $12$ students, each one of them with $2$ chances to participate, and put their names on a ball once for each of their chances.
So we have $24$ balls with names of $12$ students (each name twice).

Now we put balls in row in any order.

So now let's take $2$ barriers to divide balls onto $3$ sets: **...*| **...*|**...* .
We want to know how many possibilities of such distribution.
When we put barriers next to the balls : **..*|| we see that we have $24+2=26$ positions and we have to choose $2$ from $14$ positions for barriers -> so we have $\binom{26}{2}$ possibilities.

So now we know that there are $\binom{26}{2}$ possibilities of dividing students onto $3$ competitions.
But we want to consider order in this distributions, because we distinguish order in the ranking list.

So we multiply $\binom{26}{2}$ by $24!$ because there are $24!$ possibilities of balls distribution.
But some of balls are indistinguishable, because there is a copy of every ball
for a second chance of student.

So when let's choose position for first ball(f1) and it's copy(c1).
f1 _ c1 _ _... - we chose 1st position for f1 and 3rd for c1
c1 _ f1 _ _... - we chose 3rd position for f1 and 1st for c1
We count this as $2$ possibilities, but from our point of view
f1 _ f1 _ _...
f1 _ f1 _ _...
ball and it's copy are the same ball.

To get rid of the redundant possibilities we will divide our result by $2$ for every distinct ball, because earlier for every two positions we swapped indistinguishable balls once and got another possibility.

So the final answer is: $$\frac{\binom{26}{2} * 24!}{2^{12}} = 49\ 229\ 914\ 688\ 306\ 352\ 000\ 000 $$

0
On

Suppose we have $s$ students and $t$ tournaments, and that each student signs up for exactly $n$ (not necessarily distinct) tournaments. The space of signup configura can be represented by

$$\mathscr C(n,t,s) = \left\{C \in \{0,1,\dots,n\}^{t\times s}\,\middle |\, \forall j \in \{1,\dots,s\},\, \sum_{i=1}^{t}\,C_{ij} = n\right\},$$

where $C_{ij}$ indicates the number of times player $j$ has signed up for tournament $i$. The condition $\sum_{i=1}^{t}\,C_{ij} = n$ indicates that each player will sign up exactly $n$ times.

Now, for each signup configuration $C$, there are $R(C)$ possible rankings, where

$$R(C) = \prod_{i=1}^t\underbrace{\frac{\left(\sum_{j=1}^{s}C_{ij}\right)!}{\prod_{j=1}^{s} C_{ij}!}}_{\text{possible rankings for tournament $i$}} $$

Hence, the answer can be calculated as

$$T(n,t,s) = \sum_{C\in \mathscr C(n,t,s)}\, R(C)$$


By stars and bars, there are $\binom{n+t-1}{n}$ possibilities for each column of $C\in \mathscr C(n,t,s)$, so that

$$|C(n,t,s)| = {\binom{n+t-1}{n}}^s$$

For our problem, we have $n=2$, $t=3$ and $s=12$, so $\binom{n+t-1}{n} = \binom{4}{2} = 6$ and hence $|\mathscr C(2,3,12)| = 6^{12} = 2,176,782,336$.

We can make an algorithm to calculate $T(2,3,12)$, and $|\mathscr C(2,3,12)|$ should give us an idea of the algorithm complexity. We could calculate $R(C)$ for every $C\in \mathscr C(2,3,12)$, but that would ignore many of the symmetries involved.


Given a configuration $C \in \mathscr C(2,3,12)$, let

  • $x_1(C)$ be the number of columns $(1,1,0)$ in $C$;
  • $x_2(C)$ be the number of columns $(1,0,1)$ in $C$;
  • $x_3(C)$ be the number of columns $(0,1,1)$ in $C$;
  • $y_1(C)$ be the number of columns $(2,0,0)$ in $C$;
  • $y_2(C)$ be the number of columns $(0,2,0)$ in $C$;
  • $y_3(C)$ be the number of columns $(0,0,2)$ in $C$.

Define an equivalence relation $\sim$ on $\mathscr C(2,3,12)$ by

$$C_1 \sim C_2 \iff \forall i \in\{1,2,3\},\, x_i(C_1) = x_i(C_2)\,\text{ and }\, y_i(C_1) = y_i(C_2).$$

Letting $\mathcal C(2,3,12) = \mathscr C(2,3,12)/\sim$, we may write

$$T(2,3,12) = \sum_{Q\,\in\, \mathcal C(2,3,12)}\, |Q|\cdot \mathcal R(Q),$$

where $\mathcal R(Q)$ is defined as $R(C)$ for any $C \in Q$. Notice that this is well defined because $C_1 \sim C_2$ $\implies R(C_1) = R(C_2)$. Any class $Q$ can be uniquely identified by a tuple of non-negative integers $(a_1,a_2,a_3,b_1,b_2,b_3)$ that solves

$$a_1 + a_2 + a_3 + b_1 + b_2 + b_3 = 12\tag{1}$$

via $a_i = x_i(C)$ and $b_i = y_i(C)$ for any $C\in Q$. With this, we have that

$$|Q| = \pmatrix{ a_1+a_2+a_3+b_1+b_2+b_3\\ a_1,\,a_2,\,a_3,\,b_1,\,b_2,\,b_3 },$$

and

$$\mathcal R(Q) = \frac{ (a_1+a_2+2b_1)! }{ 2^{b_1} }\cdot \frac{ (a_1+a_3+2b_2)! }{ 2^{b_2} }\cdot \frac{ (a_2+a_3+2b_3)! }{ 2^{b_3} } .$$

Hence, if $S$ is the set of solutions to $(1)$ in the non-negative integers we have

$$ T(2,3,12) = \sum_{(a_1,a_2,a_3,b_1,b_2,b_3)\,\in\, S}\, \pmatrix{ a_1+a_2+a_3+b_1+b_2+b_3\\ a_1,\,a_2,\,a_3,\,b_1,\,b_2,\,b_3 } \cdot \frac{ (a_1+a_2+2b_1)! }{ 2^{b_1} }\cdot \frac{ (a_1+a_3+2b_2)! }{ 2^{b_2} }\cdot \frac{ (a_2+a_3+2b_3)! }{ 2^{b_3} } .$$


We can write a python program to calculate $T(2,3,12)$.

import math
numerator = math.factorial(12)

def calculate_total(l = None):
    global total                   #This variable will hold the summation
    """Recursively calculates the total possible rankings by building the possible solutions to
                                a_1+a_2+a_3+b_1+b_2+b_3 = 12
    in a list."""

    if l == None:                  #Initiate the list by assigning a value to a_1 (0 to 12)
        for i in range(13):
            calculate_total([i])

    elif len(l)==6:                #The list is complete, compute the associated summand and add it to the total
        cardinality_Q = numerator
        for i in l:
            cardinality_Q //= math.factorial(i)
        tournament_1_rankings = math.factorial(l[0] + l[1] + 2*l[3])//(2**l[3])
        tournament_2_rankings = math.factorial(l[0] + l[2] + 2*l[4])//(2**l[4])
        tournament_3_rankings = math.factorial(l[1] + l[2] + 2*l[5])//(2**l[5])
        total += cardinality_Q * tournament_1_rankings * tournament_2_rankings * tournament_3_rankings

    elif len(l) == 5:              #If 5 of the numbers are already defined, there is only one possiblity for the last
        new_l = list(l)+[12 - sum(l)]
        calculate_total(new_l)

    else:
        s = sum(l)                 #Otherwise, the next number in the list can be anything betwen 0 and what's left get to 12
        for i in range(13 - s):
            new_l = list(l) + [i]
            calculate_total(new_l)

total = 0
calculate_total()
total

The result from a %%timeit shows that it runs as

30.1 ms ± 100 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

with JupyterLab's online notebook (see here), so this approach seems computationally feasible for similar larger problems. If I made no mistake in the code, the answer turns out to be:

$$T(2,3,12) = 49229914688306352000000$$