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:||C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.