--0-67600498-11863267209483
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable

I found this Quiz to be extremely easy. I wrote this solution in a minute or two:

dict = File.open("wordlist.txt"){|f| f.readlines.reject {|word|
  ('A'..'Z') === word[0,1]}}

base = ARGV[0].to_i

puts dict.select{|word| word.unpack("C*").select{|char|
  char > ?a+base-11}.empty?}

----- Original Message ----
From: Ruby Quiz <james / grayproductions.net>
To: ruby-talk ML <ruby-talk / ruby-lang.org>
Sent: Friday, August 3, 2007 8:01:18 AM
Subject: [QUIZ] Numbers Can Be Words (#133)

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!

Suggestion:  A [QUIZ] in the subject of emails about the problem helps everyone
on Ruby Talk follow the discussion.  Please reply to the original quiz message,
if you can.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

by Morton Goldberg

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 14o 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 wanto allow capitalized
words (I prohibited them)? Do you want to restrict the bases allowed (I didn't)?








       
____________________________________________________________________________________Ready for the edge of your seat? 
Check out tonight's top picks on Yahoo!V. 
http://tv.yahoo.com/
--0-67600498-11863267209483--