# How avoid to memorize 1 billion useless data

I am a newbie Mathematica user

I wanted to know, using brute force, how many non empty triplets $$\{A_1,A_2,A_3\}$$ of subsets of $$AA=\{1,2,3,4,5,6,7,8,9,10\}$$ satisfy the conditions

• $$A_1\cup A_2\cup A_3=AA$$
• $$A_i\cap A_j=\emptyset, j\ne j$$

I thought to use

AAA = Subsets[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}];
Select[Flatten[
Table[{Union[a, b, c] == AA && Intersection[a, b] == {} &&
Intersection[b, c] == {} && Intersection[a, c] == {}, a, b,
c}, {a, AAA}, {b, AAA}, {c, AAA}], 2], #[[1]] &]


Then I realized that I was building a Table containing $$2^{30}$$ elements and that it was useless because I just needed to know if the element of the table satisfy or not the conditions.

This kind of problem happened many times before, so I am looking for an advice to program properly this kind of query.

Thank you for your attention

• Am I missing something here? 3-3 2^z+3^z for integer z>=3 length of AA (10 in your case)...
– ciao
Nov 26, 2020 at 1:42

Sum[10!/(i1! (i2 - i1)!  (10 - i2)!), {i1, 1, 8}, {i2, i1 + 1, 9}]