Hide

Problem A
Set!

/problems/set/file/statement/en/img-0001.png
Set is a card game designed by Marsha Falco in 1974 which is marketed by Set Enterprises, Inc. It also appears in syndicated form on the website of the New York Times. The player is shown 12 cards (see illustration), each of which contains $1$, $2$, or $3$ symbols. The symbols are either diamonds, squiggles, or ovals. Symbols are drawn using either a solid, striped, or open fill style. Each symbol’s color is either red, green, or purple. On a given card, all symbols are of the same type, same color, and have the same fill style.

To make a set, you must select three cards for which all $4$ characteristics are either the same or pairwise different. For instance, $3$ cards where the first shows $2$ striped red ovals, the second shows $3$ striped green squiggles, and the third shows $1$ striped purple diamond form a set. They show $2$, $3$, and $1$ symbols (each has a different number); they show ovals, squiggles, and diamonds (each shows a different shape); they use colors red, green, and purple ($3$ different colors); and lastly, they all share the same fill style: striped.

Write a program that finds all sets for $12$ provided cards!

Input

The input to your program will consist of $4$ lines, each containing $3$ strings representing $3$ cards, each consisting of four characters $ABCD$ where

  • $A \in \{ \texttt{1}, \texttt{2}, \texttt{3}\} $, corresponding to the number of symbols.

  • $B \in \{ \texttt{D}, \texttt{S}, \texttt{O}\} $, corresponding to diamonds (D), squiggles (S), and ovals (O).

  • $C \in \{ \texttt{S}, \texttt{T}, \texttt{O}\} $, corresponding to solid (S), striped (T), and open (O) fill styles.

  • $D \in \{ \texttt{R}, \texttt{G}, \texttt{P}\} $, corresponding to red (R), green (G), and purple (P).

Think of the cards as being arranged in the input as follows:

+----------+
|  1  2  3 |
|  4  5  6 |
|  7  8  9 |
| 10 11 12 |
+----------+

Output

Output all sets you can find, one per line. For each set, output the numbers of the card in the set in sorted order. The sets should be listed in sorted order using the number of their first card, breaking ties using the numbers of the second and third card in the set.

If no sets can be formed, output “no sets”. (Do not include any punctuation.)

The sample input/output corresponds to the illustration.

Sample Input 1 Sample Output 1
3DTG 3DOP 2DSG
1SOP 1DTG 2OTR
3DOR 3STG 2DSP
3SSP 3OTG 1DTP
1 8 11
2 9 12
3 7 12
5 7 9
6 8 12
7 10 11

Please log in to submit a solution to this problem

Log in