Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: OT: How to find anagrams?

by eric256 (Parson)
on Apr 27, 2004 at 23:50 UTC ( [id://348672]=note: print w/replies, xml ) Need Help??


in reply to OT: How to find anagrams?

You could further restrict the search to only words that contain those and only those letters. Thats a fairly quick regex with a character class and you've significantly reduced your word sets. MySQL (if you have your database in that) will even let you use regex in a query although i don't know if that will be faster or slower than doing them on your end.

I had a program once that took a set of rules and found all words that matched them, it could normaly be done in a single SQL statment but adding a temporary table saved a lot of time and shoehorning. :)

What is your source of words?


___________
Eric Hodges

Replies are listed 'Best First'.
Re: Re: OT: How to find anagrams?
by MidLifeXis (Monsignor) on Apr 28, 2004 at 18:07 UTC

    You could generate an SQL statement (on other DBs) such as...

    SELECT word FROM words WHERE length(word) = N AND word like '%A%A%' (if there are 2 'A' in the orig) AND word like '%B%' (if there is 1 'B' in the orig) ... ...
    to get all of your candidates.

    Of course, this assumes that your word list is in a DB.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-20 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found