------ art_101470_5947738.1168387876561 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 1/9/07, Daniel Finnie <danfinnie / optonline.net> wrote: > > > One thing I can see to optimize in your method is all the sorting. I > haven't tested the performance yet, but sets might be the answer. > > require 'set' > > class String > def letters > split(//).to_set > end > end > > baseWordSet aseWord.letters > dict.select {|x| x.letters.subset?(baseWordSet)} > > It's more readable, IMHO, at least. > > Dan I used sets in my submission, and the letters of each 6 letter word were split in the above fashion so as to provide faster scanning (at least according to one of the books I was reading the night before - please correct me if I'm wrong). The answers to these questions was actually what I was hoping to hear when I said any feedback would be appreciated :) And yes, it's definitely more readable - I wrestled with the idea of how to see if one array was a subset of another (and which way was more efficient) when I came across the concept of a set for the first time. s2.subset?(s1) sure made life easy and using it made it a lot easier to understand what my code was doing just by reading it. One last question, which I've been thinking about but not able to dedicate a lot of time to is this: how do you 'benchmark' the speed of individual programs? I've been wondering how fast my program is compared to others since I wrote it. And finally, here's to you, Mr. Ruby Quiz creator guy, for coming up with a Ruby quiz that really peaked my interest :) ------ art_101470_5947738.1168387876561--