R
Ruby Quiz
The three rules of Ruby Quiz:
1. Please do not post any solutions or spoiler discussion for this quiz until
48 hours have passed from the time on this message.
2. Support Ruby Quiz by submitting ideas as often as you can:
http://www.rubyquiz.com/
3. Enjoy!
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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.
This week's quiz 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.
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 sensative, 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.
1. Please do not post any solutions or spoiler discussion for this quiz until
48 hours have passed from the time on this message.
2. Support Ruby Quiz by submitting ideas as often as you can:
http://www.rubyquiz.com/
3. Enjoy!
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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.
This week's quiz 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.
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 sensative, 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.