Let S be the set of all seven-digit numbers that can be formed using the digits 0, 1 and 2. For example, 2210222 is in S, but 0210222 is NOT in S. Then the number of elements x in S such that at least one of the digits 0 and 1 appears exactly twice in x, is equal to .
Answer
762
Solution
Let A: 0 appears exactly twice; B: 1 appears exactly twice. Find n(A) + n(B) - n(A B).
n(A): the two 0s go in the last 6 places, 62 = 15; other 5 places from \1, 2\: 25. n(A) = 480.
n(B): all strings 7225 = 672 minus those starting with 0: 6224 = 240. n(B) = 432.
n(A B): digits 0, 0, 1, 1, 2, 2, 2: 7!2! 2! 3! = 210 minus those starting with 0: 6!2! 3! = 60. n(A B) = 150.
Required number = 480 + 432 - 150 = 762.
Answer: 762