Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Anagram finder

Anagram finder

Scheduled Pinned Locked Moved The Weird and The Wonderful
regexcsharpdatabasequestion
12 Posts 7 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    justastupidgurl
    wrote on last edited by
    #1

    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

    J A C D 4 Replies Last reply
    0
    • J 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

      J Offline
      J Offline
      Jeroen De Dauw
      wrote on last edited by
      #2

      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!

      J 1 Reply Last reply
      0
      • J Jeroen De Dauw

        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!

        J Offline
        J Offline
        justastupidgurl
        wrote on last edited by
        #3

        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

        J 1 Reply Last reply
        0
        • J 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

          J Offline
          J Offline
          Jeroen De Dauw
          wrote on last edited by
          #4

          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!

          J 1 Reply Last reply
          0
          • J Jeroen De Dauw

            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!

            J Offline
            J Offline
            justastupidgurl
            wrote on last edited by
            #5

            Go ahead

            JustAStupidGurl

            1 Reply Last reply
            0
            • J 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

              A Offline
              A Offline
              akidan
              wrote on last edited by
              #6

              ? You seem reasonably intelligent to me... or was it tongue-in-cheek?

              I J 2 Replies Last reply
              0
              • A akidan

                ? You seem reasonably intelligent to me... or was it tongue-in-cheek?

                I Offline
                I Offline
                Ian Shlasko
                wrote on last edited by
                #7

                Please adjust your sarcasm detector :)

                Proud to have finally moved to the A-Ark. Which one are you in? Developer, Author (Guardians of Xen)

                1 Reply Last reply
                0
                • J 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

                  C Offline
                  C Offline
                  ClementsDan
                  wrote on last edited by
                  #8

                  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.

                  J D 2 Replies Last reply
                  0
                  • C ClementsDan

                    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.

                    J Offline
                    J Offline
                    justastupidgurl
                    wrote on last edited by
                    #9

                    :)

                    JustAStupidGurl

                    1 Reply Last reply
                    0
                    • A akidan

                      ? You seem reasonably intelligent to me... or was it tongue-in-cheek?

                      J Offline
                      J Offline
                      justastupidgurl
                      wrote on last edited by
                      #10

                      What do you think? But then I'm JustAStupidGirl, so you never know.

                      JustAStupidGurl

                      1 Reply Last reply
                      0
                      • C ClementsDan

                        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.

                        D Offline
                        D Offline
                        dawmail333
                        wrote on last edited by
                        #11

                        *Stab* :laugh:

                        1 Reply Last reply
                        0
                        • J 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

                          D Offline
                          D Offline
                          dojohansen
                          wrote on last edited by
                          #12

                          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.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups