phone numbers
It has become quite common these days for businesses to associate their telephone numbers with words that people can remember more easily. For example, Sears Canada's catalogue number is: 1-800-26-SEARS.
The digits 2-9 on a telephone key pad are each associated with three letters of the alphabet:
| 2 | A-B-C | 6 | M-N-O |
| 3 | D-E-F | 7 | P-R-S |
| 4 | G-H-I | 8 | T-U-V |
| 5 | J-K-L | 9 | W-X-Y |
Notice that the digits 1 and 0 do not have letters associated with them. Notice also that only 24 letters are represented. The letters Q and Z are not in the table.
Your job is to write a program that will take a 7-digit phone number and generate a list of possible words that can be associated with it using a standard mapping of digits to letters. Since there are 3 possible letters for each digit, for a 7-digit number, there are approximately 37 = ~2200 possibilities. If you also include 6-letter words, there are an additional 36 = ~725 (assuming you only choose on the last 6 digits and not the first). There are ~250 5-letter words and finally ~80 4-letter words (assuming again you only check the rightmost digits). This makes a grand total of 3250 different combinations.
This is a very long list. In order to keep the output to this program manageable, let's look only for 5-letter words. This would leave the first 2 digits of the number in their "raw" state. Even then, we should be able to eliminate a fair number of these using a few simple approaches:
Even with the ability to eliminate a fair number of candidates, the list is likely to be quite long. Make sure you format you output to print more than one phone-word per line.
When you run your program, re-direct output to a file so you don't need to see all the output.
If you are doing more than 5-digits DO NOT print the entire output file!!!! Instead use UNIX's 'head' and 'tail' commands to display the first and last 50-100 lines.
BONUS:
Updated: