Serving the Quantitative Finance Community

 
User avatar
mensa0
Topic Author
Posts: 0
Joined: January 20th, 2004, 8:56 am

Phone Number Enumeration Teaser

July 5th, 2007, 5:51 am

The seven digits in the modern U.S. phone numbering system (i.e. without area code) have some restrictions on the values they may assume:1. The first digit cannot be a zero or a one (these are reserved for “Operator” and long distance access, respectively.) 2. The first three digits cannot be “911” – these are reserved for emergency calls.3. The first three digits cannot be “555” – (Ever wonder why phone numbers given out or written down in movies or on TV begin 555?)4. The last four digits may not be zero-zero-zero-zero.How many possible valid phone numbers are there? I'd be interested in your approach to whatever solution you obtain. Thanks!Mike(I get 7,979,202 but I'm not 100% sure it's correct)
 
User avatar
zarnywhoop
Posts: 0
Joined: December 2nd, 2004, 5:39 pm

Phone Number Enumeration Teaser

July 5th, 2007, 7:24 am

This is arithmetic, not a brainteaser.
 
User avatar
Paolos
Posts: 1
Joined: November 12th, 2004, 2:15 pm

Phone Number Enumeration Teaser

July 5th, 2007, 7:25 am

I agree with 7,979,202without any restrictions there are 10e6 combinations.Restriction 1 reduces the valid phone numbers to 8e6Restrictions 2 & 3 reduce the possible combinations to 7,980,000 (there are 10000 seven digits numbers that begin with "911" and other 10000 with "555")Restriction 4 reduces by 798 the combinations (there are 1000 seven digits numbers that end with "0000" but "1##0000","0##0000", "9110000" and "555000" are already excluded)P.Brute Force Proof (copy & paste in VBA);Public Sub phone()Dim i As LongDim j As LongDim st As StringFor i = 0 To 9999999st = Format(i, "0000000") If Left(st, 1) <> "1" And Left(st, 1) <> "0" And Left(st, 3) <> "911" And Left(st, 3) <> "555" And Right(st, 4) <> "0000" Then j = j + 1 End IfNext iMsgBox jEnd Sub
Last edited by Paolos on July 4th, 2007, 10:00 pm, edited 1 time in total.
 
User avatar
MikeCrowe
Posts: 0
Joined: January 16th, 2006, 8:20 am

Phone Number Enumeration Teaser

July 5th, 2007, 7:33 am

I agree with that figure.By restricting the first digit to 2..9 we have 8,000,000Less 10,000 that start 911Less 10,000 that start 555Less 800 that end 0000 and start with 2..9Plus the 2 numbers 9110000 and 5550000 that we counted twice