Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: OT: How to find anagrams?

by Plankton (Vicar)
on Apr 28, 2004 at 19:30 UTC ( [id://348920]=note: print w/replies, xml ) Need Help??


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)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://348920]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-25 22:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found