Hi, I have two questions:
you can assume a number to appear only once
the numbers always start with 00 but can be shorter or longer that 13 digits in their overall legnth; this is because telephone numbers from all over the world vary in length
thanks dishdy for precizing those details
We can create a function to do it. Is it OK?
No functions allowed!
See Note 1 on the challenge home page.
What if there are two equal-length matches i.e. a dialed number such as 0012049179 in the sample data? Do we report both or report first match only?
Unless I misunderstood your question, in my opinion it should be obvious that in the data you will get two different local numbers for the same area code.
The only odd case you'll need to deal with is when there is no matching area code. And in that case you should not display the number in your result.
So my sample number of 0012049179 would report as:
Dialed Number PFX
0012049179 1204 Canada-Manitoba
0012049179 9179 Ahmedabad-India
i.e. two lines in the output?
You need to distinguish between the prefix and the local number. In your example 0012049179, 1204 is the prefix and 9179 is the local number. Why are you also interpreting 9179 as if it were a prefix?
I would like say show
"0012049179 1204 Canada-Manitoba" only, Remember the area code always starts from beginning.
Managed Windows Shared Hosting by OrcsWeb