The problem I am solving is:
Determine all possible values of positive integer $n$, such that there are $n$ different $3$-element subsets $A_1,A_2,...,A_n$ of the set $\{1,2,...,n\}$, with $|A_i \cap A_j| \not= 1$ for all $i \not= j$.
I already know that every $n=4k$ satisfies the conditions. I am verifying this with the following code:
n = 4;
sets = Subsets[Range[n], {3}]
AllTrue[Length /@ Intersection @@@ Subsets[sets, {2}], # != 1 &]
However, when I set $n = 8$, the result is False
, which is incorrect.
How can I fix my code?
n
different 3-element subsets that satisify this condition for any integer n>3. In fact (kind of unrelated but interesting), there is a closed form for the number of 3-element subsets satisfying your condition: $\frac{1}{72} (-3 + n) (-2 + n) (-1 + n) n (38 + (-9 +n) n)$ $\endgroup$