From: James Koppel Date: 2007-08-06T00:12:02+09:00 Subject: Re: [QUIZ] Numbers Can Be Words (#133) --0-67600498-1186326720=:49483 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 o= r two:=0A=0Adict =3D File.open("wordlist.txt"){|f| f.readlines.reject {|wor= d|=0A ('A'..'Z') =3D=3D=3D word[0,1]}}=0A=0Abase =3D ARGV[0].to_i=0A=0Aput= s dict.select{|word| word.unpack("C*").select{|char|=0A char > ?a+base-11}= .empty?}=0A=0A----- Original Message ----=0AFrom: Ruby Quiz =0ATo: ruby-talk ML =0ASent: Friday, A= ugust 3, 2007 8:01:18 AM=0ASubject: [QUIZ] Numbers Can Be Words (#133)=0A= =0AThe three rules of Ruby Quiz:=0A=0A1. Please do not post any solutions = or spoiler discussion for this quiz until=0A48 hours have passed from the t= ime on this message.=0A=0A2. Support Ruby Quiz by submitting ideas as ofte= n as you can:=0A=0Ahttp://www.rubyquiz.com/=0A=0A3. Enjoy!=0A=0ASuggestion= : A [QUIZ] in the subject of emails about the problem helps everyone=0Aon = Ruby Talk follow the discussion. Please reply to the original quiz message= ,=0Aif you can.=0A=0A-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-= =3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D= -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D=0A=0Aby Morton Goldberg=0A=0AWhen working = with hexadecimal numbers it is likely that you've noticed some hex=0Anumber= s are also words. For example, 'bad' and 'face' are both English words and= =0Avalid hex numbers (2989 and 64206, respectively, in decimal). I got to t= hinking=0Athat it would be interesting to find out how many and which hex n= umbers were=0Aalso valid English words. Of course, almost immediately I sta= rted to think of=0Ageneralizations. What about other bases? What about lang= uages other than=0AEnglish?=0A=0AYour mission is to pick a word list in som= e language (it will have be one that=0Auses roman letters) and write Ruby c= ode to filter the list to extract all the=0Awords which are valid numbers i= n a given base. For many bases this isn't an=0Ainteresting task--for bases = 2-10, the filter comes up empty; for bases 11-13,=0Athe filter output is un= interesting (IMO); for bases approaching 36, the filter=0Apasses almost eve= rything (also uninteresting IMO). However, for bases in the=0Arange from 14= to about 22, the results can be interesting and even surprising,=0Aespecia= lly if one constrains the filter to accept only words of some length.=0A=0A= I used `/usr/share/dict/words` for my word list. Participants who don't hav= e=0Athat list on their system or want a different one can go to Kevin's Wor= d List=0APage (http://wordlist.sourceforge.net/) as a source of other word = lists.=0A=0ASome points you might want to consider: Do you want to omit sho= rt words like 'a'=0Aand 'ad'? (I made word length a parameter). Do you want= to allow capitalized=0Awords (I prohibited them)? Do you want to restrict = the bases allowed (I didn't)?=0A=0A=0A=0A=0A=0A=0A=0A=0A =0A_________= ___________________________________________________________________________= Ready for the edge of your seat? =0ACheck out tonight's top picks on Yahoo!= TV. =0Ahttp://tv.yahoo.com/ --0-67600498-1186326720=:49483--