2006 Indonesia MO Problems/Problem 6

Problem

Every phone number in an area consists of eight digits and starts with digit $8$. Mr Edy, who has just moved to the area, apply for a new phone number. What is the chance that Mr. Edy gets a phone number which consists of at most five different digits?

Solution

We can do complementary counting to determine the number of phone numbers that have more than 5 different digits. We will divide into separate cases on the last seven digits.

Case 1: Two 8s, Five other numbers appearing once The two eights has seven spots available, so there are $\tfrac{7 \cdot 6}{2} = 21$ ways to place the eights. Since there are nine other digits and five available spots left for each placement of the two 8s, there are $21 \cdot 9 \cdot 8 \cdot 7 \cdot 6 \cdot 5 = 317520$ phone numbers in this case.

Case 2: One 8, Six other numbers appearing once The eight has seven spots available. Since there are nine other digits and six available spots, there are $7 \cdot 9 \cdot 8 \cdot 7 \cdot 6 \cdot 5 \cdot 4 = 423360$ phone numbers in this case.

Case 3: One 8, Four other numbers appearing once, One other number appearing twice Consider the four solo numbers as a group and the one repeat number as a group. There are $\tfrac{7!}{2!4!} = 105$ ways to place the three groups (where the remaining slot goes to the one 8). There are nine digits for the one repeat, which leaves eight distinct digits for the group of solo numbers. Thus, there are $105 \cdot 9 \cdot 8 \cdot 7 \cdot 6 \cdot 5 = 1587600$ phone numbers in this case.

Case 4: Zero 8s, Seven other numbers appearing once Since there are nine other digits and seven available spots, there are $9 \cdot 8 \cdot 7 \cdot 6 \cdot 5 \cdot 4 \cdot 3 = 181440$ phone numbers in this case.

Case 5: Zero 8s, Five other numbers appearing once, One other number appearing twice There are nine digits to choose for the digit appearing two times, and there are $\tbinom{7}{2} = 21$ ways to place the recurring digit. For each placement of each repeating digit, there are eight other digits with five open slots, so there are $9 \cdot 21 \cdot 8 \cdot 7 \cdot 6 \cdot 5 \cdot 4 = 1270080$ phone numbers in this case.

Case 6: Zero 8s, Three other numbers appearing once, Two other numbers appearing twice First consider the number of ways to order the two numbers appearing twice in a four number string. One can note that in the string $AABB$, there are $\tbinom{4}{2} = 6$ ways to order the letters. Additionally, there are 9 possible digits for $A$ and 8 possible digits for $B$. However, we are overcounting since $A$ and $B$ can be swapped, so there are $\tfrac12 \cdot 6 \cdot 9 \cdot 8 = 216$ ways to order the two numbers appearing twice in a four number string.

Now consider the number of ways to order $AAABBBB$. There are $\tbinom{7}{4} = 35$ ways to order the letters. The letter $B$ represents the group of numbers that appear twice, which are already ordered in the above paragraph. That leaves three slots left with 7 available digits, so there are a total of $216 \cdot 35 \cdot 7 \cdot 6 \cdot 5 = 1587600$ phone numbers in this case.

Case 7: Zero 8s, Four other numbers appearing once, One other number appearing three times There are nine digits to choose for the digit appearing three times, and there are $\tbinom{7}{3} = 35$ ways to place the recurring digit. For each placement of each repeating digit, there are eight other digits with four open slots, so there are $9 \cdot 35 \cdot 8 \cdot 7 \cdot 6 \cdot 5 = 529200$ phone numbers in this case.


Adding up all the cases results in a total of $5896800$ phone numbers with more than five distinct digits. The total number of phone numbers is $10^7 = 10000000$, so there are $10000000 - 5896800 = 4103200$ phone numbers with at most five distinct digits. Thus, the probability that Mr. Edy gets a phone number with at most five distinct digits is $\tfrac{4103200}{10000000} = \boxed{0.41032}$.

Python Code

Although Python programs are not allowed in the Indonesia MO, a computer program can be used to manually count every single phone number that has at most 5 distinct digits.

 count = 0
 number = [0,0,0,0,0,0,0]
 for i in range(0,10000000):
 
     # Reset
     numberlist = [0,0,0,0,0,0,0,0,1,0]
 
     # Count Digit
     for digit in number:
         numberlist[digit] += 1
 
     # Count Zeroes (we want 5 or less)
     zerocounter = 0
     for result in numberlist:
         if result == 0:
             zerocounter += 1
     if zerocounter >= 5: #since at most 5 digits are used, at least 5 digits are unused
         count += 1
   
 
     # Next Number
     number[len(number)-1] += 1
 
     # Regroup if Necessary
     for j in range(0,len(number)):
         if number[len(number)-1-j] == 10:
             number[len(number)-1-j] = 0
             if len(number)-1-j > 0:
                 number[len(number)-2-j] += 1
 
 print(count)

The computer program verifies that there are $4103200$ phone numbers that satisfies the conditions, which confirms that the probability is $\boxed{0.41032}$.

See Also

2006 Indonesia MO (Problems)
Preceded by
Problem 5
1 2 3 4 5 6 7 8 Followed by
Problem 7
All Indonesia MO Problems and Solutions