[Math] How many 5-digit zip codes can there be with exactly two digits the same

combinatoricspermutations

How many 5-digit United States zip codes can there be with exactly one pair of digits? This includes both zip codes that correspond to an actual city, town, incorporated community, ghost town, etc. in the United States and zip codes that are not used currently.

Exactly one pair of digits means only two digits in a zip code can be the same, but the digits do not necessarily have to be next to each other.

Example zip codes that count:

  • 99501 (Anchorage, AK) has one pair of $9$'s
  • 02108 (Boston, MA) has one pair of $0$'s
  • 63155 (St. Louis, MO) has one pair of $5$'s

Example zip codes that do not count:

  • 59103 (Billings, MT) does not have any two digits to be the same
  • 78727 (Austin, TX) has three–not two–digits to be the same
  • 93388 (Bakersfield, CA) has two pairs–not one pair–of digits

I appealed to the fundamental counting principle, as usual.

Number of zip codes whose…

  • first two digits are the same (e.g. 99501): $10 \cdot 10 \cdot 9 \cdot 8 \cdot 7$
  • first and fourth digits digits the same (e.g. 02108): $10 \cdot 9 \cdot 8 \cdot 10 \cdot 7$
  • fourth and fifth digits are the same (e.g. 63155): $10 \cdot 9 \cdot 8 \cdot 7 \cdot 7$

…etc.

Was that correct or not? I thought since order matters in writing a zip code that I had to consider all those cases. If so, how can I consider all possible cases using a combinatorial argument, with permutations specifically?

(I have little background in combinatorics, but I am nonetheless curious. This is not a homework question; hence, my curiosity for asking this here.)

Best Answer

I presume you're talking about a $5$-digit zip code (not ZIP+4). To choose a zip code satisfying your condition, choose an ordered $4$-tuple of distinct digits from $0$ to $9$ ($10 \times 9 \times 8 \times 7 = 5040$ ways to do this), then choose an unordered pair of positions out of the $5$ (${5 \choose 2} = 10$ ways, and assign the $4$-tuple in order to this pair and the other positions. The total number of such codes is thus $5040 \times 10 = 50400$.