In a game of 27 cards, each card has three characteristics: shape (square, circle, or triangle), color (blue, yellow, or red), and type of coloring (solid, dotted, or hatched). All cards are different. A combination of three cards is called complementary if, for each of the three characteristics, the three cards are identical, or all different. How many complementary combinations are there.
Consider a pair of cards, chosen at random. Then there is a unique card allowing to complete this pair into a complementary combination. Indeed, consider one of the characteristics of our two cards, for example the shape. If the two cards have the same shape (say a square), then a card forming a complementary combination with our two cards is necessarily of the same shape (thus square). Now, if the two cards have two different shapes (say a circle and a triangle), then a card forming a complementary combination with our two cards is necessarily of the third shape (thus square). In all cases, the shape of the third card is perfectly determined. Each pair therefore gives us a complementary combination. Thus, each combination is counted three times (since if $(A, B, C)$ is a complementary combination, the three initial choices of pair $(A, B),(B, C)$ and $(C, A)$ lead to the combination $(A, B, C)$). The number of complementary combinations is therefore $\frac{1}{3}\binom{27}{2}=117$.