CAT 2021 Slot 3QA Question 9

Numbers (P&C)Easy

A four-digit number is formed by using only the digits 1, 2 and 3 such that both 2 and 3 appear at least once. The number of all such four-digit numbers is 

Answer & solution

Answer: 50

Solution

Medium

Each of the four positions takes a digit from {1,2,3}\{1,2,3\} with the constraint that 22 and 33 each appear at least once. The cleanest count is complementary: from all arrangements, remove those missing a 22 or missing a 33, using inclusion–exclusion.

1

Count all four-digit strings. Each position independently takes one of 33 digits.

Total=34=81\begin{aligned} &\text{Total}=3^4=81 \end{aligned}
2

Remove the "missing" cases (inclusion–exclusion). Strings with no 22 use only {1,3}\{1,3\}; strings with no 33 use only {1,2}\{1,2\}; strings with neither 22 nor 33 use only {1}\{1\}.

no 2=24=16no 3=24=16no 2 and no 3=14=1\begin{aligned} &|\text{no }2|=2^4=16\\ &|\text{no }3|=2^4=16\\ &|\text{no }2\text{ and no }3|=1^4=1 \end{aligned}
3

Subtract. Valid count == total - (missing 22) - (missing 33) ++ (missing both), adding back the doubly-removed overlap.

Valid=811616+1(from steps 1, 2) =50\begin{aligned} &\text{Valid}=81-16-16+1 \quad\text{(from steps 1, 2)}\\ &\Rightarrow\ =50 \end{aligned}
Need a hint?

You can also case-split by digit multiset (e.g. {2,3,1,1}\{2,3,1,1\} gives 4!2!=12\tfrac{4!}{2!}=12, etc.) and add the six cases: 12+12+12+6+4+4=5012+12+12+6+4+4=50. Inclusion–exclusion is faster.

Number of such numbers=50\text{Number of such numbers}=50
CAT 2021 Slot 3 QA Q9: A four-digit number is formed by using only the digits 1, 2 and 3 such that both 2 and 3 appear at least once. — Solution | TheCATExam