The three rules of Ruby Q.:
-
Please do not post any solutions or spoiler discussion for this quiz
until
48 hours have passed from the time on this message. -
Support Ruby Q. by submitting ideas as often as you can:
- Enjoy!
Suggestion: A [QUIZ] in the subject of emails about the problem helps
everyone
on Ruby T. follow the discussion. Please reply to the original quiz
message,
if you can.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
by Morton G.
When working with hexadecimal numbers it is likely that you’ve noticed
some hex
numbers are also words. For example, ‘bad’ and ‘face’ are both English
words and
valid hex numbers (2989 and 64206, respectively, in decimal). I got to
thinking
that it would be interesting to find out how many and which hex numbers
were
also valid English words. Of course, almost immediately I started to
think of
generalizations. What about other bases? What about languages other than
English?
Your mission is to pick a word list in some language (it will have be
one that
uses roman letters) and write Ruby code to filter the list to extract
all the
words which are valid numbers in a given base. For many bases this isn’t
an
interesting task–for bases 2-10, the filter comes up empty; for bases
11-13,
the filter output is uninteresting (IMO); for bases approaching 36, the
filter
passes almost everything (also uninteresting IMO). However, for bases in
the
range from 14 to about 22, the results can be interesting and even
surprising,
especially if one constrains the filter to accept only words of some
length.
I used /usr/share/dict/words
for my word list. Participants who don’t
have
that list on their system or want a different one can go to Kevin’s Word
List
Page (http://wordlist.sourceforge.net/) as a source of other word lists.
Some points you might want to consider: Do you want to omit short words
like ‘a’
and ‘ad’? (I made word length a parameter). Do you want to allow
capitalized
words (I prohibited them)? Do you want to restrict the bases allowed (I
didn’t)?