From: James Edward Gray II Date: 2007-01-11T22:59:00+09:00 Subject: Re: [SUMMARY] Word Blender (#108) On Jan 11, 2007, at 7:54 AM, Martin DeMello wrote: > On 1/11/07, Ruby Quiz wrote: >> >> The main trick used in this recursive grouping of words is the use of >> "signatures." A word's signature is just the sorted order of the >> letters in the >> word: aejms for james, for example. Comparing signatures makes >> it trivial to >> find words that use the same letters, since their signatures will >> be the same. >> >> Using the signatures, the choices() method just removes one >> character at a time >> recursing through the word list. This allows me to find all of >> the smaller >> words that can be formed using the same letters. > > I used a different signature method - I mapped each unique letter in > the target word to a prime, and then used the product of the primes of > all the letters in a word as its signature. That way, a is contained > in b if signature(b) % signature(a) == 0, and you can generate the > signatures via each_byte, array lookup and integer multiplication (no > need for split, sort or string deletion). Very interesting. I've never seen that before. I like it. My version of "signatures" comes out of Programming Peals, if my memory is right. Just FYI. James Edward Gray II