andrea wrote:
> Thanks a lot everyone, now I already posted but don't know why it
> doesn't appear my message.
> Anyway you're right Axel, this is the first "solution" to the problem
> but it's really too slow for any reasonable large size of the string.
>
> This is the code, any hint about style or whatever is welcome:
> http://pastie.textmate.org/private/rp4ivw36vefuz07twjlw3g
>
>
> I'll have a look to the Markov Chain (which I'm studying right now at
> uni).
>   

Just for fun/reference, this is what I came up with after reading your 
post earlier. Note that it doesn't do the "of any length" requirement, 
though.


require 'rubygems'
require 'raspell'

def anagrams word
        checker = Aspell.new
        word.split(//).permutation.select { |w| checker.check w.join 
}.map { |w| w.join }
end

puts anagrams "words"


-Justin