27
2
Background
Set is a card game. The deck consists of 81 unique cards that vary in four features: number of shapes (one, two, or three), shape (diamond, squiggle, oval), shading (solid, striped, or open), and color (red, green, or purple).
For convenience, let's write a card as a 4-tuple of numbers from 1 to 3, e.g.
1111
= one red solid diamond1122
= one red striped squiggle1223
= one green striped oval2312
= two purple solid squiggle
Given several cards (usually 12), the objective of the game is to find a "set" of three cards such that
- They all have the same number or have three different numbers.
- They all have the same shape or have three different shapes.
- They all have the same shading or have three different shadings.
- They all have the same color or have three different colors.
i.e. the cards are either all the same or all different in each of the four features.
Here are some examples of sets:
1111, 1112, 1113
1111, 2222, 3333
2312, 3321, 1333
Here are some examples of non-sets:
1111, 1122, 1123
2131, 3221, 1213
A cap set is a collection of cards that doesn't contain any Set. It was proven in 1971 that the maximum number of cards without a Set is 20. Interestingly, finding the largest cap set for the generalized game of Set is still an open problem in mathematics.
The Wikipedia page shows an example of 20-cap set, and here is the 20 cards in the number notation:
1111, 1113, 1131, 1133,
1312, 1332, 1321, 1323,
3311, 3313, 3331, 3333,
3112, 3132, 3121, 3123,
1222, 2122, 2322, 3222
There are 682344 20-cap sets in total, but under affine transformations on 4-dimensional finite space, they all reduce to essentially one cap set.
Task
Output any of the 20-cap sets in the game of Set.
Input and output
Your program/function is not allowed to take input.
The output is a collection (list, set, ...) of 20 cards which is a cap set. Each card should be represented as a 4-tuple (or equivalent ordered collection) whose elements are one of three distinct values (not necessarily 1, 2, 3). Flexible output applies in the following ways:
- Nested or flattened list
- Ordering of cards doesn't matter
- You may choose to output the same set or different set across runs
- For string/text output, it's fine as long as we can clearly identify the structure (20 chunks of four items) of the output
Verification script example in Python using the example shown above.
Scoring and winning criterion
Standard code-golf rules apply. The shortest valid code in bytes wins.
3@Arnauld Neither. You can choose to output the same set or different set across runs. – Bubbler – 2019-11-11T09:16:59.873
6For anyone that wants to make use of it, we can specify a cap set as all
(a,b,c,d)
from{0,1,2}^4
witha*a+b*b+c*d=0 (mod 3)
except for(0,0,0,0)
. – xnor – 2019-11-11T09:35:17.1204
So I understand, would this count as a boring brute force solution? And so then the game becomes either "find a formula like xor's for generating one of these" or, perhaps, search the entire space of all of them for one that can be compactly represented with some packing function? If the latter, would a
– Jonah – 2019-11-11T16:45:29.633kolmogorov-complexity
tag be in order?I'm with Jonah. The task does not require computing, just compressing. – Mindwin – 2019-11-11T18:33:18.853
4@Jonah Yes, that is a valid solution, though it's arguably a boring one. And yes, it's a compression challenge. No, I don't think it's [tag:kolmogorov-complexity], since you can choose from
682344 * 20! / (some constant)
possible outputs. Also, I can think of at least three approaches to this problem: 1) compress a cleverly chosen cap set 2) enumerate all 20-card sets and pick one that is a cap set 3) use math formula. – Bubbler – 2019-11-11T23:20:36.460Fair enough, @Bubbler. Thanks for explaining. – Jonah – 2019-11-11T23:22:22.837