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.