Subsets of three numbers from a set of n numbers such that no two subsets have a shared pair of numbers

85 Views Asked by At

I've had this problem for a long time. The problem goes as follows (it is a bit hard to say concisely): Let's say, for example, I have the numbers 1-9 (n=9) and am looking to arrange these numbers in sets of three where no two sets have the same pair of numbers (e.g. 123 and 345 would be acceptable to have together because they don't share any pair of numbers, but 123 and 124 wouldn't be acceptable because they share the pair of numbers 12). As far as I am aware, the optimal way to arrange the numbers 1-9 contains the following sets of three (the numbers might be able to be moved around, but the idea is the same): 123, 456, 789, 147, 258, 369, 159, 357, 168, 348, 267, and 249, yielding 12 sets of three. The problem I still have is I don't know anything above 9, and I don't know the general formula to solve for any n (which is preferable because that would give me the answer to the previous problem). I don't have any sort of general formula in mind, but I do have the numbers 1-9 as n (the maximum number) solved:

1: 0,

2: 0,

3: 1 (123),

4: 1 (123 or 124 or 134 or 234),

5: 2 (123 and 345 etc.),

6: 4 (123 and 345 and 146 and 256),

7: 7 (123, 345, 146, 256, 157, 247, 367),

8: 8 (123, 456, 147, 258, 357, 168, 348, 267 using a different method to get the numbers),

and 9: 12 (123, 456, 789, 147, 258, 369, 159, 357, 168, 348, 267, 249).

I also know that the n's which use all possible pairs of numbers that could be made up to n (e.g. 12, 13, 14, 23, 24, and 34 for n=4) can only be numbers which are either a multiple of 3 or 1 plus a multiple of three. I also feel it is important to mention that I have practically no knowledge of how to code, but I imagine that that would probably be the easiest way to get the solution. In short, the question I am trying to answer is what is the general formula for the number of sets of three numbers that can be formed up to n without a pair of numbers repeating? (I feel it is also important to mention that I am not using strictly technical math terms here because a. I don't know them and b. I don't think it changes the answer to the question.)

Additionally, although I only covered sets of three, I would also like to know sets of four without repeated pairs, sets of four without repeated triplets, and so on such that I know the number of sets of x without y repeated numbers up to n.

Edit: Thanks to the comment from Daniel Mathias this got, (I now know) the entire question is answered within the first bullet point under the history section on the Wikipedia article titled Kirkman's schoolgirl problem.

1

There are 1 best solutions below

0
On

You want to find the maximum number of triples, such that no two triples intersect in two or more places. This is known as a packing design. Finding optimal packing designs is an area of open research; the paper by Chee et al cited at the end has some partial results.

Let $P_n$ be the largest number of triples $\{1,\dots,n\}$ you can select, subject to the rules. We can prove that $$ P_n\le \left\lfloor \frac n3 \left\lfloor \frac{n-1}2\right\rfloor \right\rfloor,\tag1 $$ as follows. For each $k\in \{1,\dots,n\}$, there are at most $\lfloor\frac{n-1}2\rfloor $ triples which contain $k$. This is because, when you remove $k$ from those triples, what remains are several disjoint pairs of elements. This means there are at most $n\times \lfloor\frac{n-1}2\rfloor$ ways to choose a pair $(k,T)$, such that $k\in \{1,\dots,n\}$, and such that $T$ is a triple containing $k$. On the other hand, there are $P_n\times 3$ ways to choose $(k,T)$, because there are $P_n$ choices for $T$, and then $3$ ways to choose $k$ from $T$. We conclude that $3\times P_n\le \lfloor\frac{n-1}2\rfloor$, which is equivalent to $(1)$. This bound is known more generally as the Johnson bound, according to Chee et al.

In the case where $n\equiv 1$ or $3\pmod 6$, the above becomes $$ n\equiv 1\text{ or }3\pmod 6\quad \implies \quad P_n\le \frac{n(n-1)}{6} $$ In fact, in this cases we can always obtain equality, and the resulting list of triples will be a Steiner triple system. This means that every pair of numbers from $\{1,\dots,n\}$ appears together in a triple exactly once. See the Skolem paper for the details of a construction.

According to the CRC Handbook of Combinatorial Designs, the upper bound in $(1)$ is attainable, except for when $n\equiv 5 \pmod6$, in which case you can only get that upper bound minus one. The construction for $n\equiv 0,2\pmod 6$ is easy; just take a Steiner triple system of order $n+1$ and delete the number $n+1$, and all triples containing $n+1$. For $n\equiv 4,5\pmod 6$, the construction is a bit more complicated; you will have to consult the handbook for the construction, in the Packings chapter (chapter 40 page 550 in the second edition).

Charles J. Colbourn and Jeffrey H. Dinitz. 2006. Handbook of Combinatorial Designs, Second Edition (Discrete Mathematics and Its Applications). Chapman & Hall/CRC.

Skolem, T. (1958). Some Remarks on the Triple Systems of Steiner. MATHEMATICA SCANDINAVICA, 6, 273-280. https://doi.org/10.7146/math.scand.a-10551

Yeow Meng Chee, Charles J. Colbourn, Alan C.H. Ling, Richard M. Wilson, Covering and packing for pairs, Journal of Combinatorial Theory, Series A, Volume 120, Issue 7, 2013, Pages 1440-1449, ISSN 0097-3165, https://doi.org/10.1016/j.jcta.2013.04.005.