Valid phone number
All submissions for this problem are available.
Telephone numbers in India are 10 digits long (excluding an initial zero which is required at times) and fall in at least four distinct categories:
- Landlines: Written as 0AAABBBBBBB, where AAA is the Subscriber Trunk Dialing code (long distance code) and BBBBBBB is the phone number. The total length of the Subscriber Trunk Dialing code and the phone number is 10 digits.
- Mobiles: Written as AAAAABBBBB for ease of remembering. Mobile numbers which are not local need to be prefixed by a 0 while dialing, or by +91 (91 is the country code for India). A mobile number written as +91AAAAABBBBB is valid throughout India, and in other countries where the + is recognized as a prefix to the country code.
- Toll Free: These are usually ten digit numbers beginning with 1800. Sometimes they are accessible (or are toll-free) only when called from the government-owned telephone corporation, BSNL/MTNL.
- Service numbers: These are usually three or four digit numbers (e.g. Police is 100) used to access an emergency service (Fire, Ambulance, Police, Roadside assistance) or a value-added service.
Please, help me in finding a given string is valid phone number or not.
Newbies, please refer to Codechef sample solution before starting to code,
The first line of input contains an integer T denoting the number of test cases.
The next T lines contains a input string S.
Output T lines, each line "true" if the string is a valid phone number and "false" if they cant.
- 0 ≤ T ≤ 1000
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.5, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.