Submit solution

Points: 3 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
2015 Mock CCC by Alex and Timothy

Area codes 416 and 647 are telephone area codes serving the single rate centre of Toronto, Ontario, Canada. However, as the city's people and organizations grow, these area codes are becoming exhausted. In 2011, the Canadian Radio-television and Telecommunications Commission (CRTC) have announced Toronto's new 437 area code.

As the years go by, the classic 416 area code is becoming more and more rare. In fact, 416 phone numbers are being sold for hundreds, even thousands of dollars. Businesspeople feel that a 647 or a 437 number gives customers a feeling that their business is not established. A 416 number tells customers that they have been in business for a while.

We will consider a valid phone number to contain 10 numerical digits in total (3 digits for the area code and 7 digits for the local number). For this problem, we will always denote a phone number by the area code, followed by a space, followed by the local number. Furthermore, since we are only concerned with businesses in central Toronto, valid phone numbers must have the area codes 416, 647, or 437. An invalid phone number is one that does not follow these rules. Examples of valid phone numbers are 416 1234567 and 437 9876543. Examples of invalid phone numbers are 647 12345678, 905 6413431 or 4161 596111.

Additionally, if a valid phone number has a 416 area code, then we will consider it to be valuable. All other valid phone numbers are valueless. Part of your job as a vendor of fine 416 numbers is to determine the value of a phone number. Of course, your life would be easier with the help of an automated program. So, write a program that when given a phone number, classifies it as either invalid, valuable, or valueless.

Input Format

The input will contain two sequences of digits separated by a single space, representing a phone number that you must classify. The first sequence will represent the area code and the second sequence will represent the local number. Neither of the sequences will exceed 9 digits in length.

Output Format

Output a single word (all lowercase), either invalid, valuable, or valueless.

Sample Input 1

416 0534865

Sample Output 1

valuable

Sample Input 2

827 9876543

Sample Output 2

invalid

Comments


  • -4
    Arihan10  commented on Feb. 5, 2019, 1:33 p.m.

    Can somebody please explain why I am getting WA on Testcase 4? Thanks.


  • 1
    LiFengxun  commented on Oct. 20, 2018, 7:37 a.m.

    can somebody look at my code, in java 8, I really got a problem with this,Thanks!!


    • 0
      AlanL  commented on Oct. 20, 2018, 12:41 p.m.

      Not sure if this helps, but when you write <9999999 it also includes values that are not 7 digits long, so that may be where you're going wrong.


  • -2
    odaniel  commented on Dec. 20, 2015, 7:52 p.m.

    All numbers that begin with "416" just so happen to be valid length-wise. Of course, that makes my one-liner solution work, but it shouldn't.


    • -1
      Pavlo87  commented on May 25, 2017, 9:56 p.m.

      Notice how this is only a 3 point problem. 3 point problems aren't meant for experienced coders, but rather for beginners. These types of problems (especially since it is a Junior 1 problem) rarely have any tricks involved. They also do not usually contain many difficult, large or corner test cases if at all. These types of problems should be taken at face value and are supposed to be one line implementation problems. In your case, I recommend trying some more difficult problems such as System(0);.