# Figuring out possible combinations with restrictions

OK, so I am choosing 4 letters/numbers out of 10 possible letters. These letters are X,Y,LT,LB,RT,RB,U,D,L,R. The first three letters can be any one of these, but must contain at least one X or Y. The last letter can be an U,D,L, or right. Can someone please figure out the possible combinations?

• Seem like you might be writing a game, if so, why don't you write to a program to generate it out? Also, you are missing A,B? – Aryabhata Feb 3 '11 at 3:31
• LT, LB, RT, RB are letters? – PrimeNumber Feb 3 '11 at 3:31

There are $10^3$ combinations without a restriction in the first three letters. Now there are $8^3$ possible combinations for the first three letters that do not contain a $Y$ nor $X$, so there are $10^3 - 8^3 = 488$ possibilities with your restrictions in the first three letters. There are 4 choices for the last letter, hence there are $488 \cdot 4 = 1952$ choices.
Oh, in case you don't allow repetition (it says "at least one $X$ or $Y$," that's a bit misleading):
Fix some letter from $U, D, L, R$ in the last position. Then you have in general $9 \cdot 8 \cdot 7 = 504$ choices for the first letter, without restrictions. $7 \cdot 6 \cdot 5 = 210$ of these choices do not have an $X$ or $Y$. So total you have $(504 - 210) \cdot 4 = 1176$ choices without repetition.