in reply to OT: How to find anagrams?

It shouldn't be to hard to adapt Jumble solver CGI to handle multiple words. Just insert a space between each letter, permute, and test the spelling of each word in the string. I don't know if the performance would be all that great, but gmax had a fast version of this here Re: Jumble solver

Plankton: 1% Evil, 99% Hot Gas.

Replies are listed 'Best First'.
Re: Re: OT: How to find anagrams?
by gnork (Scribe) on Apr 29, 2004 at 10:35 UTC
    Heres a code snippet which could help you a bit ...
    didnt use it for a long time, but AFAIR it works and returns all possible permutations for the given string.
    sub DoPermuteArray { my @array = @{ $_[0] }; my @permuted; eval (&PermuteArray(['1','1','1','1','-','--'],[],\@permuted)); return @permuted; } sub PermuteArray { # taken from the perl FAQ my @items = @{ $_[0] }; my @perms = @{ $_[1] }; my $permuted = $_[2]; my @return; unless (@items) { push (@$permuted,[@perms]); } else { my(@newitems,@newperms,$i); foreach $i (0 .. $#items) { @newitems = @items; @newperms = @perms; unshift(@newperms, splice(@newitems, $i, 1)); &PermuteArray ([@newitems], [@newperms]); } } }

    Rgds.
    Gnork

    cat /dev/world | perl -e "(/(^.*? \?) 42\!/) && (print $1))"
    errors->(c)