Code Golf: Phone Number to Words
- by Nick Hodges
Guidelines for code-golf on SO
We've all seen phone numbers that are put into words: 1-800-BUY-MORE, etc.
What is the shortest amount of code you can write that will produce all the possible combinations of words for a 7 digit US phone number.
Input will be a seven digit integer (or string, if that is simpler), and assume that the input is properly formed.
Output will be a list of seven character strings that
For instance, the number 428-5246 would produce
GATJAGM
GATJAGN
GATJAGO
GATJAHM
GATJAHN
GATJAHO
and so on.....
Winning criteria will be code from any language with the fewest characters that produce every possible letter combination.
Additional Notes:
To make it more interesting, words
can be formed only by using the
letters on a North American Classic
Key Pad phone with three letters
per number as defined here.That means that Z and Q are excluded.
For the number '1', put a space.
For the number '0', put a hyphen '-'
Bonus points awarded for recognizing output as real English words. Okay, not really. ;-)