Project Euler Problem 818
The SET® card game is played with a pack of 81 distinct cards.
Solution
Answer: 11871909492066000
Model the deck as the affine space $\mathbb F_3^4$, where each card is a 4-tuple over ${0,1,2}$.
A SET is exactly an affine line of three points satisfying
$$a+b+c=0 \pmod 3.$$
There are $1080$ SETs (affine lines). Expanding
$$S(C_n)^4$$
turns $F(n)$ into a count over ordered 4-tuples of SETs. If a 4-tuple of SETs has union size $k$, then it is contained in exactly
$$\binom{81-k}{n-k}$$
different $n$-card collections.
Thus
$$F(n)=\sum_{k=3}^{12} A_k \binom{81-k}{n-k},$$
where $A_k$ is the number of ordered 4-tuples of SETs whose union contains exactly $k$ cards.
Using symmetry classes of ordered line pairs in $AG(4,3)$ (same line, intersecting, parallel disjoint, skew disjoint), the $A_k$ values can be computed efficiently by bitset enumeration. The computation reproduces the given checks:
$$F(3)=1080,\qquad F(6)=159690960.$$
Evaluating for $n=12$ gives:
Answer: 11871909492066000