From: James Edward Gray II Date: 2005-02-24T06:42:31+09:00 Subject: Re: [SOLUTION] 1-800-THE-QUIZ (#20) On Feb 22, 2005, at 12:56 AM, Jannis Harder wrote: > Here's my code: > (wordizer.rb) I must have gremlins today. I'm breaking all kinds of programs. [snip beginning of code] > def wordize(number,mulnum=false) > number=number.to_s > numa = number.split('').map{|z|@map[z.to_i]} > positions=[[0,false]] > words = [nil]*(number.size+1) > until positions.empty? > positions.uniq! > pos,num = positions.shift > words[pos]= nil if words[pos] and words[pos].empty? > words[pos]||=@dict.grep(mkre(numa[pos..-1])) > words[pos].map{|z|z.size if z}.uniq.each do |len| > positions.push([pos+len,false]) if pos+len<=number.size > end > if ((not num) or mulnum)and pos words[pos]< !positions.include?([pos+1,false]) At first, copying and pasting this code gave me a syntax error. Changing the above to: words[pos]< begin f = File.open(dict) > ARGF.pos > rescue > $stderr.puts "#$0: #$!" > exit 1 > end Then when I would try: $ echo '873.7829' | ruby wordizer.rb -d /usr/share/dict/words The above chunk of code would issue an "Illegal Seek" error. Commenting out ARGF.pos seem to get me over that hump. However at that point, issuing the same command seems to cause an infinite loop. I couldn't figure out what was going on there, so I gave up. Just thought I would share, in case I uncovered anything... James Edward Gray II