-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstructions.txt
39 lines (25 loc) · 1.83 KB
/
instructions.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Many companies like to list their phone numbers using the letters printed on most telephones. This makes the number easier to remember for customers. A famous example being 1-800-PICK-UPS.
The problem is to write a program that will show a user possible matches for a list of provided phone numbers.
Your script should behave as a standard Unix filter, reading from files specified as command-line arguments or STDIN when no files are given. Each line of these files will contain a single phone number.
For each phone number read, your filter should output all possible word replacements from a dictionary. Your script should try to replace every digit of the provided phone number with a letter from a dictionary word; however, if no match can be made, a single digit can be left as is at that point. No two consecutive digits can remain unchanged and the program should skip over a number (producing no output) if a match cannot be made.
/* note */
When displaying a single letter or number, only use from this list.
letters - A, B, I, N, R, U
numbers - 2, 4
Your script should allow the user to set a dictionary with the -d command-line option, but it's fine to use a reasonable default for your system. The dictionary is expected to have one word per line.
All punctuation and whitespace should be ignored in both phone numbers and the dictionary file.
The program should not be case sensitive, letting "a" == "A". Output should be capital letters and digits separated at word boundaries with a single dash (-), one possible word encoding per line. For example, if your program is fed the number:
873.7829
One possible line of output is
USE-RUBY
According to my dictionary.
The number encoding on my phone is:
2 = A B C
3 = D E F
4 = G H I
5 = J K L
6 = M N O
7 = P Q R S
8 = T U V
9 = W X Y Z
Feel free to use that, or the encoding on your own phone.