Computer Science Canada [CCC 2005] Senior S1 : Snow Calls |
Author: | zylum [ Fri Mar 04, 2005 4:46 pm ] | ||||||
Post subject: | [CCC 2005] Senior S1 : Snow Calls | ||||||
[CCC 2005] Senior S1 : Snow Calls You've been snowed in at your summer residence. And without the Internet! Unfornutanetly, 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. Often times, 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 campanies 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 Input consists of a series of test cases. The first line consists of an integer t, the number of test cases. Following are t lines consisting of alpha-numeric characters separated by hyphens, representing valid phone numbers. No line is longer than 40 characters. Input will be contained in the file s1.in. Output For each test case, output the phone number in hte form xxx-xxx-xxxx to the screen. Sample Input
Sample Output
|
Author: | rizzix [ Fri Mar 04, 2005 5:03 pm ] |
Post subject: | |
This can be solved using a oneliner (more-or-less) in java using regex. obviously thats not allowed right? heh. |
Author: | zylum [ Fri Mar 04, 2005 5:15 pm ] |
Post subject: | |
ofcourse it's allowed |
Author: | Tony [ Fri Mar 04, 2005 5:25 pm ] | ||
Post subject: | |||
I know there's a much more eligant way of doing this, but since the contest is time limited, copy/paste of very simple regex's will have you working on S2 within seconds |
Author: | rizzix [ Fri Mar 04, 2005 5:33 pm ] |
Post subject: | |
yea but tony the contest does not permit Ruby. or does it? |
Author: | Hikaru79 [ Fri Mar 04, 2005 6:49 pm ] |
Post subject: | |
rizzix wrote: yea but tony the contest does not permit Ruby. or does it?
I'm pretty sure the CCC allows anything your school is making available (Round 2 is much more restrictive though). Of course, good luck finding a school that has Ruby... |
Author: | Tony [ Fri Mar 04, 2005 9:18 pm ] |
Post subject: | |
rizzix wrote: yea but tony the contest does not permit Ruby.
Stage 1 of CCC allows vertually any language other than some specialized ones such as Maple. I'm pretty sure that has to do with the fact that Maple has most of math algorythms build in. Stage 2 is limited to a select few (C++, Java, Pascal and Turing I belive... Somebody would have to confirm that), but only because University computers are used, and they can't be bothered with installing and configuring all of those compilers. Hikaru79 : like any good programming language, Ruby is free to download and use |