CCC '05 S1 - Snow Calls

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 256M

Problem type
Canadian Computing Competition: 2005 Stage 1, Senior #1

You've been snowed in at your summer residence. And without the Internet! Unfortunately, this means you're going to have to rely on using the phone to get what you need to survive: pizza, pop, and the latest video games.

Oftentimes, companies replace the digits in their phone numbers with characters to make their phone numbers more memorable. Because apparently, it's easier to remember 416-BUY-MORE than it is to remember 416-289-6673. Some companies even add extra digits or characters (like 604-PIZZABOX) but any digits after the 10th are irrelevant.

Since it's getting tedious to do the conversion by hand, write a program to help change all the phone numbers in your phone book to the form xxx-xxx-xxxx, using the below image to assist you.

Input Specification

Input consists of a series of test cases. The first line consists of an integer t, the number of test cases. Following this are t lines consisting of alphanumeric characters separated by hyphens, representing valid phone numbers. All letters will be in uppercase. No line is longer than 40 characters.

Output Specification

For each test case, output the phone number in the form xxx-xxx-xxxx to the screen.

Sample Input

5
88-SNOW-5555
519-888-4567
BUY-MORE-POP
416-PIZZA-BOX
5059381123

Sample Output

887-669-5555
519-888-4567
289-667-3767
416-749-9226
505-938-1123

Comments


  • 0
    kyw  commented on Jan. 6, 2022, 2:29 a.m.

    Could someone tell me where my code is messing up? It works perfectly fine with the test case. Thanks in advance!


    • 1
      Spitfire720  commented on Jan. 6, 2022, 1:34 p.m.

      You didn't quite cover everything for your letter conversions. PSTVWZ1111 will fail.


      • 0
        kyw  commented on Jan. 7, 2022, 1:41 a.m.

        Found it, can't believe I missed that. Thanks again!


  • 5
    LeonLiur  commented on July 27, 2020, 3:25 a.m.

    Could someone check where my code is not working? Everything seems to be working fine; Java 8 WA on case 1. Thanks a lot in advance!


    • 6
      Kirito  commented on July 27, 2020, 3:40 a.m.

      Do you account for the fact that 4, rather than 3, letters map to 7?


      • 6
        LeonLiur  commented on July 27, 2020, 4:33 a.m.

        Oh, oops, i totally ignored that. Sorry for posing a brainless question :|


  • -24
    nickshort  commented on Nov. 29, 2016, 8:54 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


    • 8
      println_hi_  commented on Nov. 30, 2016, 12:45 a.m.

      Some companies even add extra digits or characters (like 604-PIZZABOX) but any digits after the 10th are irrelevant.


  • -16
    WilliamW_0627  commented on Nov. 14, 2015, 3:09 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


    • 9
      Xyene  commented on Nov. 14, 2015, 5:17 p.m.

      There is no such case in the testdata.

      Following this are t lines consisting of alpha-numeric characters separated by hyphens, representing valid phone numbers.

      A valid phone number must have at least 10 alphanumeric characters, otherwise it's not a phone number!