Anagram finder
-
Was just asked to convert some VB6 code to C#. The purpose of the code is to find anagrams. There is a database with a list of words. The input is a string of letters and the code is supposed to spit out any matching anagrams found in the word list. The idea is to have a 'crossword puzzle' helper tool that can be downloaded from an ad-financed puzzle enthusiasts website, but the client felt it was too slow to use and wondered if C# might be faster. This is what I found: All possible orders of letters in the input string are derived in a loop, then each one is searched against the database to see if it exists. As you might imagine, with anything except a very short input this yields gazzilions of combinations and takes forever (almost literally) to run. The first thing I did was a run-once bit of code to sort the letters in each word in the database into alphabetical order, and stick that in as a key field. To find an anagram, the letters in the input are also sorted into alphabetical order. We then match that to the indexed key field and pull out matching words in the blink of an eye. The end result runs in milliseconds instead of centuries. Or as the client put it "That C#'s a bit faster than VB6, isn't it?" Should I now point out that a downloadable C# app is not a good idea? Their user base (presumably little old ladies) would need the net framework on their Win98 PCs, and having downloaded once, they don't need to go back to click on the knitting pattern banner ads. It should run in a browser. But what do I know? I'm just a stupid girl.
JustAStupidGurl
-
Was just asked to convert some VB6 code to C#. The purpose of the code is to find anagrams. There is a database with a list of words. The input is a string of letters and the code is supposed to spit out any matching anagrams found in the word list. The idea is to have a 'crossword puzzle' helper tool that can be downloaded from an ad-financed puzzle enthusiasts website, but the client felt it was too slow to use and wondered if C# might be faster. This is what I found: All possible orders of letters in the input string are derived in a loop, then each one is searched against the database to see if it exists. As you might imagine, with anything except a very short input this yields gazzilions of combinations and takes forever (almost literally) to run. The first thing I did was a run-once bit of code to sort the letters in each word in the database into alphabetical order, and stick that in as a key field. To find an anagram, the letters in the input are also sorted into alphabetical order. We then match that to the indexed key field and pull out matching words in the blink of an eye. The end result runs in milliseconds instead of centuries. Or as the client put it "That C#'s a bit faster than VB6, isn't it?" Should I now point out that a downloadable C# app is not a good idea? Their user base (presumably little old ladies) would need the net framework on their Win98 PCs, and having downloaded once, they don't need to go back to click on the knitting pattern banner ads. It should run in a browser. But what do I know? I'm just a stupid girl.
JustAStupidGurl
Very amuzing :-D The old algorithm does not hold into account possible typo's. Maybe it can be adapted to also check for every possible combination of 3 wrong characters in each word :-D
GSoC 2009 student for SMW! --- My little forums: http://code.bn2vs.com --- 70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
-
Very amuzing :-D The old algorithm does not hold into account possible typo's. Maybe it can be adapted to also check for every possible combination of 3 wrong characters in each word :-D
GSoC 2009 student for SMW! --- My little forums: http://code.bn2vs.com --- 70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
Or make the input several MB. It could then produce every possible C# source code file, not to mention every possible poem of that size. Bound to be a few good ones :)
JustAStupidGurl
-
Or make the input several MB. It could then produce every possible C# source code file, not to mention every possible poem of that size. Bound to be a few good ones :)
JustAStupidGurl
lol! Mind if I put that in my collection of epic quotes? ;P
GSoC 2009 student for SMW! --- My little forums: http://code.bn2vs.com --- 70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
-
lol! Mind if I put that in my collection of epic quotes? ;P
GSoC 2009 student for SMW! --- My little forums: http://code.bn2vs.com --- 70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
Go ahead
JustAStupidGurl
-
Was just asked to convert some VB6 code to C#. The purpose of the code is to find anagrams. There is a database with a list of words. The input is a string of letters and the code is supposed to spit out any matching anagrams found in the word list. The idea is to have a 'crossword puzzle' helper tool that can be downloaded from an ad-financed puzzle enthusiasts website, but the client felt it was too slow to use and wondered if C# might be faster. This is what I found: All possible orders of letters in the input string are derived in a loop, then each one is searched against the database to see if it exists. As you might imagine, with anything except a very short input this yields gazzilions of combinations and takes forever (almost literally) to run. The first thing I did was a run-once bit of code to sort the letters in each word in the database into alphabetical order, and stick that in as a key field. To find an anagram, the letters in the input are also sorted into alphabetical order. We then match that to the indexed key field and pull out matching words in the blink of an eye. The end result runs in milliseconds instead of centuries. Or as the client put it "That C#'s a bit faster than VB6, isn't it?" Should I now point out that a downloadable C# app is not a good idea? Their user base (presumably little old ladies) would need the net framework on their Win98 PCs, and having downloaded once, they don't need to go back to click on the knitting pattern banner ads. It should run in a browser. But what do I know? I'm just a stupid girl.
JustAStupidGurl
-
Please adjust your sarcasm detector :)
Proud to have finally moved to the A-Ark. Which one are you in? Developer, Author (Guardians of Xen)
-
Was just asked to convert some VB6 code to C#. The purpose of the code is to find anagrams. There is a database with a list of words. The input is a string of letters and the code is supposed to spit out any matching anagrams found in the word list. The idea is to have a 'crossword puzzle' helper tool that can be downloaded from an ad-financed puzzle enthusiasts website, but the client felt it was too slow to use and wondered if C# might be faster. This is what I found: All possible orders of letters in the input string are derived in a loop, then each one is searched against the database to see if it exists. As you might imagine, with anything except a very short input this yields gazzilions of combinations and takes forever (almost literally) to run. The first thing I did was a run-once bit of code to sort the letters in each word in the database into alphabetical order, and stick that in as a key field. To find an anagram, the letters in the input are also sorted into alphabetical order. We then match that to the indexed key field and pull out matching words in the blink of an eye. The end result runs in milliseconds instead of centuries. Or as the client put it "That C#'s a bit faster than VB6, isn't it?" Should I now point out that a downloadable C# app is not a good idea? Their user base (presumably little old ladies) would need the net framework on their Win98 PCs, and having downloaded once, they don't need to go back to click on the knitting pattern banner ads. It should run in a browser. But what do I know? I'm just a stupid girl.
JustAStupidGurl
The impressiveness of (for example) a 87,178,291,200-element search space for 14-letter anagrams should have gotten the original author to use less permissiveness in choosing an algorithm. If he could miss such an obvious rectification for the problem, he doesn't deserve to earn any kind of certification in software development.
-
The impressiveness of (for example) a 87,178,291,200-element search space for 14-letter anagrams should have gotten the original author to use less permissiveness in choosing an algorithm. If he could miss such an obvious rectification for the problem, he doesn't deserve to earn any kind of certification in software development.
:)
JustAStupidGurl
-
What do you think? But then I'm JustAStupidGirl, so you never know.
JustAStupidGurl
-
The impressiveness of (for example) a 87,178,291,200-element search space for 14-letter anagrams should have gotten the original author to use less permissiveness in choosing an algorithm. If he could miss such an obvious rectification for the problem, he doesn't deserve to earn any kind of certification in software development.
*Stab* :laugh:
-
Was just asked to convert some VB6 code to C#. The purpose of the code is to find anagrams. There is a database with a list of words. The input is a string of letters and the code is supposed to spit out any matching anagrams found in the word list. The idea is to have a 'crossword puzzle' helper tool that can be downloaded from an ad-financed puzzle enthusiasts website, but the client felt it was too slow to use and wondered if C# might be faster. This is what I found: All possible orders of letters in the input string are derived in a loop, then each one is searched against the database to see if it exists. As you might imagine, with anything except a very short input this yields gazzilions of combinations and takes forever (almost literally) to run. The first thing I did was a run-once bit of code to sort the letters in each word in the database into alphabetical order, and stick that in as a key field. To find an anagram, the letters in the input are also sorted into alphabetical order. We then match that to the indexed key field and pull out matching words in the blink of an eye. The end result runs in milliseconds instead of centuries. Or as the client put it "That C#'s a bit faster than VB6, isn't it?" Should I now point out that a downloadable C# app is not a good idea? Their user base (presumably little old ladies) would need the net framework on their Win98 PCs, and having downloaded once, they don't need to go back to click on the knitting pattern banner ads. It should run in a browser. But what do I know? I'm just a stupid girl.
JustAStupidGurl
Do point out that a downloadable C# app isn't the best idea. Why not just run it in asp.net? Even if the existing website is something else, like php, why not set up an asp.net server to run the anagram logic if nothing else? The site can then retrieve the anagrams (or even pre-rendered html) through ajax or some ajax-like mechanism and nobody has to download anything. Even people who have the framework installed may be somewhat sceptical to downloading and running executables directly from some small-name website. Though I guess if we look at how many people happily use things like TPB as their source of software my concern might seem exaggerated. I've always been fascinated by the fact that somewhere in the digits of pi is a blue-ray encoded video with DTS surround sound of myself falling into a supermassive black hole, seeing past and future as I pass the event horizon, and then arriving at a concert where Mozart plays drums, Britney Spears plays a cello, Bono is a backing vocalist and the pope is making out with George Michael.