As the title states, I am writing a program that takes a bunch of random letters and turns them into english words. I have gotten the program to output every variation of the inputted letters, but its hard searching through them all for actual english words. How would I go about checking the output against an english dictionary? Any help would be appreciated!
First of all you need to store the dictionary somehow. There are a few ways you could do this ranging from a straightforward array to using a database. Probably the most efficient way would be to use some sort of tree structure. The top level nodes which each contain single letters of the alphabet; the second level nodes (up to 26 per first-level node) would contain a single letter which is a possible second letter for a word (so for 'a' there would probably be 26 second-level nodes, for 'q' only one or two), etc. To check a word against the dictionary you just check that the first letter is one of the first-level nodes, the second one of the second-level nodes for that first-level one, etc. That's probably the most efficient way of storing the dictionary for quick searches.
Of course the biggest problem is inputting the dictionary initially....
I'm not sure if this is at all doable, but just emptying my brain out on the page. Would it be possible to query a pre-existing database (such as dictionary.com's)? As ijack said, the initial creation of said dictionary would be a pain.
I would read each line into a String (using StreamReader.ReadLine), or you could even read the whole file (using StreamReader.ReadToEnd) if it's not too big. Then split the String into words (using String.Split) at which point you can do the character-by-character comparison. An alternative would be to just read each character from the file (using StreamReader.Read) and create each word yourself. One thing that you need to be aware of is the possibility of end-of-line breaks (denoted by a hyphen); all depends upon what you know about the input file. In any case, actually extracting the individual words from the text file shouldn't be too difficult.