Imagine you have a sequence of cards, each having a unique set of features.
Example features : letter (A, B, C), number (1, 2, 3), and color (Red, Green, Blue)
Some example cards : A1Red, B1Blue, C3Green, B2Red, etc.
I want to find patterns made of 3 cards. The rules are that for these 3 cards to "match", within a single feature, all cards must be different, or the same.
For example, just looking at the "letter" feature. ABC is a match, BBB is a match, and AAC, BAA, etc. are not.
So for a whole set example:
A1Red, B2Green, C3Blue = match
B3Green, B3Green, B3Green, = match
C2Red, C2Blue, C2Green = match
B1Red, C1Green, A1Blue = match
A1Red, A2Blue, A1Green = NOT match (two 1s)
B2Green, A1Red, C3Red = NOT match (two reds)
So if I lay out a random 16 cards, how many matches can I expect to find in there? More generically, how many matches can I expect to find in X cards?