login
A380167
Maximum number of sets for the SET card game for n cards with 3 properties where each can take 3 values.
0
1, 1, 2, 3, 5, 8, 12, 12, 13, 14, 16, 19, 23, 26, 30, 36, 41, 47, 54, 62, 71, 81, 92, 104, 117
OFFSET
3,3
COMMENTS
Also the maximum number of lines for n points in F_3^3 where a line is defined as three points p, q, r such that p+q+r = 0.
EXAMPLE
For n=3, the maximum number of SETs with 3 cards is 1 hence a(3)=1.
For n=4, no additional SETs can be formed, hence a(4)=1.
For n=5, we can take a 3-card SET, say {p, q, r}. Then, for two additional cards, s and t, outside of the SET, the only possible way this can form a SET is if we have one element from the first SET plus s and t form a SET. An example of this with the 4 properties being coordinates from 0 to 2 in mod 3 (in the equivalent definition of a SET) is the points {(0, 0, 0, 0), (0, 0, 0, 1), (0, 0, 0, 2), (0, 0, 1, 0), (0, 0, 2, 0)} which form 2 SETs. Hence a(5)=2.
PROG
(Python)
from itertools import combinations
def add_mod3(a, b, c):
"""Component-wise addition mod 3 of two 3D tuples."""
return tuple((a[i] + b[i] + c[i]) % 3 for i in range(3))
def is_set(a, b, c):
"""Returns true if three elements form a set."""
return add_mod3(a, b, c) == (0, 0, 0)
if __name__ == "__main__":
all_points = [(x, y, z) for x in range(3) for y in range(3) for z in range(3)]
max_sets = 0
for n in range(3, 28):
for comb in combinations(all_points, n):
num_sets = 0
for possible_set in combinations(comb, 3):
if is_set(possible_set[0], possible_set[1], possible_set[2]):
num_sets += 1
if num_sets > max_sets:
max_sets = num_sets
print("Max sets for %d cards: %d"%(n, max_sets))
CROSSREFS
Cf. A090245 for a complementary sequence of the maximum number of cards with no sets.
Cf. A182240 for the number of ways to select n cards which is the search space complexity of this sequence for 4 properties instead of 3.
Sequence in context: A105766 A056695 A342746 * A287006 A020899 A057987
KEYWORD
nonn,fini,full
AUTHOR
Justin Stevens, Jan 22 2025
STATUS
approved