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

1,756

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$.

Share:
1,756
Cookie
Author by

Cookie

Updated on January 24, 2020

Comments

  • Cookie
    Cookie almost 4 years

    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.)

    • JMoravitz
      JMoravitz almost 7 years
      For "Fourth and Fifth digits the same" for example, once you have chosen the fourth digit there is no longer any choice to be made for the fifth, it must match the fourth in order to ensure it matches. You pick the result of the fourth and fifth simultaneously, making it only $10\cdot 9\cdot 8\cdot 7\color{grey}{\cdot 1}$ for this case. Now... how many cases are there? Could you explain this more easily without cases by deciding where the matching numbers are beforehand?
    • Cookie
      Cookie almost 7 years
      Position cases: (1,2), (1,3), (1,4), (1,5), (2,3), (2,4), (2,5), (3,4), (3,5), (4,5). So there are 10 cases, I believe.
    • JMoravitz
      JMoravitz almost 7 years
      and how many ways can you choose two of the positions out of five (order not mattering) to place the matching numbers... five choices and we want to choose two of them. Instead of wasting time and effort writing them all out by hand as you have (because it is time consuming and prone to making mistakes), is there a convenient calculation we can make?
    • Cookie
      Cookie almost 7 years
      There are $5 \choose 2$ ways. However, I thought order matters in writing a zip code. That's why I wrote them all out initially.
    • JMoravitz
      JMoravitz almost 7 years
      Order of the numbers matter, yes., but we aren't talking about numbers right now, we are talking about positions to be filled by repeated numbers. Positions five and three matching is the same result as positions three and five matching.
    • Cookie
      Cookie almost 7 years
      I see now: since two numbers have to be repeating, regardless of the position, then the number of zip codes with, say, first two digits are matching (e.g. 99801) is actually $10 \cdot 1 \cdot 9 \cdot 8 \cdot 7$. It does not matter where the $1$ is placed in computations like that one (for e.g. fourth and fifth repeating digits, second and fourth, etc.); obviously every quantity will always be $10 \cdot 9 \cdot 8 \cdot 7$, no matter the positions. And then there are ${5 \choose 2 }= 10$ such positions. Hence, $(10 \cdot 9 \cdot 8 \cdot 7) \cdot (10)=50400$, just like @RobertIsrael's answer.
    • Cookie
      Cookie almost 7 years
      If now three digits in a zip code must match, then there are $(10 \cdot 9 \cdot 8) \cdot {5 \choose 3} = 7200$ such zip codes.
  • jonask
    jonask almost 7 years
    What would be the result if the first digit could not be 0?
  • Cookie
    Cookie almost 7 years
    It should be $5040 \times 10 = 50400$, not $3024 \times 10$