![]() |
Programming Exercise #2
Problem: Make an anagram finder.
Say what?!? An anagram is a word that uses the same letters as another word. For example, santa and satan are anagrams. The exercise is to propose and/or code the best and most efficient way to find all anagrams for a word. For our purposes, assume you're using an english dictionary. Go go go |
PHP Code:
PHP Code:
|
Quote:
|
Quote:
|
Quote:
edit: Recursion can be used to get the arrangements, working on that... |
Quote:
|
Quote:
|
Quote:
|
I'm not gonna write it out, but I say just have a script that links to a website that solves anagrams :o
|
Quote:
edit: NPC Code:function arrange(letters,first) { Now I just need some inDictionary(word). |
Quote:
|
I guess we should just load those word combinations generated, with some dictionairy script (it's around here somewhere).
*swings magic wand to gather post* Quote:
|
Quote:
|
Quote:
Is that cheating? Although, it probably isn't very efficient in terms of the memory needed to hold such a list... |
Quote:
|
PHP Code:
Edit getwordlist() at the bottom to return the wordlist used. I used a wordlist which I uploaded to temp (if anyone wants to try with that I can rar it and attach, but you might need to edit it (graal doesn't like to loop through 317k words :()) :O And.. don't hurt me if this isn't a good anagram finder :( |
Quote:
In a perfect world, we could have a dictionary in a sort of hash table: NPC Code:function anagrams( word ) TADAA |
Quote:
|
Quote:
|
I'm guessing this hasn't been touched long enough no one will add to this.
I would have presorted a file of all known words with the letters arranged in alphabetical order, then just saved that and used it until the end of time. example line from file: aanst=santa,satan,etc then when given a word, sort it and look it up (very fast). now if someone wants to take the best shot coding the sorting of the word file and the look up in gscript... |
Quote:
http://forums.graalonline.com/forums...ad.php?t=81856 |
Quote:
edit: I just watched the video and it makes me think that it might be slower than that even... |
All times are GMT +2. The time now is 03:36 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.