From: Ben Tilly Date: 2001-01-03T04:21:52+09:00 Subject: [ruby-talk:8533] Re: speedup of anagram finder "SHULTZ,BARRY (HP-Israel,ex1)" wrote: [...] >I don't think there's a future for this solution, but it got me thinking >about diophantine solutions to >this problem, just because sums are computed faster than products. >Yesterday >I started thinking >about limiting and defining the problem this way: > >Let n = number of letters in an "alphabet" >Let m = maximum number of letters in a word > >Find an equation > >a1X1 + ... + anXn = 0 > > so that the solution set does not contain anything that could break the >algorithm that computes the >integral index I want. > >Trivial first case: n = 2. a1 = 1, a2 = m + 1 works. > >Any feedback would be appreciated. This is sick. :-) Those with some math will know that e=exp(1) is transcendental. This was proved by Hermite in 1873. From that it is trivial that exp(0.1) is also transcendental. Therefore no linear combination (with integer coefficients) of exp(0.1), exp(0.2), ..., exp(3.0) can be 0 except the trivial one. This allows us to come up with a hashing function using floating point numbers. The only issue is what point we will get into pain from round-off errors. Just map the characters onto convenient fractional powers of e and add them together. Cheers, Ben _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com