If I have a set of $n$ items $\{ A, B, C, D, ... \}$ from which I need to choose $r$ items and I am aware the formula for the number of combinations is:
$$\frac{n!}{ r!(n - r)!}$$
(Note, in my use-case, $r$ is always 3).
However, in my case each item may (but need not) have a variation (indicated here by a prime), so the set could be, for example, $\{ A, A', B, B', C, D \}$.
I want to choose 3 items from the set such that you may not choose a primed and non-primed item of the same letter and you may choose at most one primed item. If there are no primed items in the set then you may choose only non-primed items.
So from the above set $\{ A, B', C, D\}$ is legal but $\{ A, A', B, C \}$ and $\{ A', B', C, D \}$ are not.
I have noted that adding the first primed item to the set doesn't change the number of combinations (due to the rule that if there are none, then none need be used) so this may require an exception. After that, the number of combinations appears to be proportional to the number of primed items, however I am unable to derive the complete formula. Any help would be appreciated.