Phone Phun

View as PDF

Submit solution

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

Author:
Problem types
Allowed languages
Java, Lisp, Rust
enter image description here

Vanity phone numbers are phone numbers where some of the numbers are replaced with letters, they're mainly used by businesses to be more memorable. The system that relates letters to their numbers was soon standardized, and is shown to the right (each box contains a number and the letters that correspond to that number).

Sadly some keypads don't have the letters on them. Can you make a program that translates vanity numbers into standard phone numbers.

Input Specification

A single line that's 14 characters long. The line will made up of a combination of numbers, capital letters, or - (dash).

Output Specification

A single line that's 14 characters long. It should consist of all the letters replaces with their appropriate numbers.

Sample Input

1-800-GOLF-TIP

Sample Output

1-800-4653-847

Sample Explanation

The first 6 characters are either numbers, or - so they don't have to be changed.

The 7th character is a G, looking at the keypad image it's in the same square as 4, so that's what it should be replaced with.

Continuing with this strategy, the rest of the number is replaces with numbers, except the last - which is kept as such.


Comments

There are no comments at the moment.