Back

Solution: 2014 Winter Midterm - 5

Author: Michiel Smid

Question

A password consists of 12 or 13 characters, each character being one of the 10 digits $0,1,2,\dots,9$. A password must contain the digit 7 at least once. How many passwords are there?
(a)
$10^{12} + 10^{13} - 9^{12} - 9^{13}$
(b)
$12^{10} + 13^{10} - 12^{7} - 13^{7}$
(c)
$12^{10} + 13^{10} - 12^{9} - 13^{9}$
(d)
$10^{12} + 10^{13} - 7^{12} - 7^{13}$

Solution

We can subtract the number of passwords that do not contain the digit 7 from the total number of possibilities.

  • For 13 characters, there are $10^{13}$ total possibilities.
  • For 13 characters, there are $9^{13}$ possibilities that do not contain the digit 7.
  • For 12 characters, there are $10^{12}$ total possibilities.
  • For 12 characters, there are $9^{12}$ possibilities that do not contain the digit 7.

Thus, the number of passwords that contain the digit 7 at least once is $10^{13} - 9^{13} + 10^{12} - 9^{12}$