Mock CCC '15 J1 - 416

View as PDF

Submit solution

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

Author:
Problem type
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) has 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 Specification

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 Specification

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


  • 2
    VictorZhu  commented on Feb. 1, 2023, 3:59 a.m.

    Personally wouldn't recommend jumping from a Junior 1 problem straight to a Senior 3 problem.


  • -3
    Arihan10  commented on Feb. 5, 2019, 6:33 p.m.

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


    • 2
      dchoo333  commented on Sept. 18, 2021, 12:39 p.m.

      It's supposed to be area code 437. Your program is checking for area code 436.


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

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


    • 1
      AlanL  commented on Oct. 20, 2018, 4: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.


  • -3
    odaniel  commented on Dec. 21, 2015, 12:52 a.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 26, 2017, 1:56 a.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);.