CAT 2021 Slot 3 — QA Question 9
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
Medium
Each of the four positions takes a digit from with the constraint that and each appear at least once. The cleanest count is complementary: from all arrangements, remove those missing a or missing a , using inclusion–exclusion.
Count all four-digit strings. Each position independently takes one of digits.
Remove the "missing" cases (inclusion–exclusion). Strings with no use only ; strings with no use only ; strings with neither nor use only .
Subtract. Valid count total (missing ) (missing ) (missing both), adding back the doubly-removed overlap.
Need a hint?
You can also case-split by digit multiset (e.g. gives , etc.) and add the six cases: . Inclusion–exclusion is faster.