Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 132,682 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,230 people online right now. Registration is fast and FREE... Join Now!




Sorting word list

 
Reply to this topicStart new topic

Sorting word list

c2z232f
post 25 May, 2008 - 05:01 PM
Post #1


New D.I.C Head

*
Joined: 25 May, 2008
Posts: 1

[code]
StreamReader textFile = new StreamReader("WordList.txt");
StreamWriter write = new StreamWriter("List3.txt", false);
do
{
string text = textFile.ReadLine();
if (text.Length == 3)
write.WriteLine(text);
} while (!textFile.EndOfStream);
MessageBox.Show("done");
[code]

There is a game on face book called scramble (also known as boggle) where you have a 3x3 or 4x4 grid of letters and have to find the words in the grid ranging from 3 to 8 letters.

I have made a program that will find the words. my only problem is that it is really slow because the word list that it checks from is extremely long. So I want to make the word list into many different lists sorted by number of letters.

I have created such a program with the code above. The code works perfectly and fast. My only problem is that when the program writes so many words it just stops writing. For instance when I tried to put all of the 3 letter words in a file it got down to the word "tat" after that it wont write any more to the file. I have tried debugging it and it looks like it should keep writing it just doesn't. I already tried doing it in two lists but it only adds a few more words not all of them. I think it might be a memory overload problem but I'm not sure how to fix it.
User is offlineProfile CardPM

Go to the top of the page

baavgai
post 25 May, 2008 - 05:20 PM
Post #2


Dreaming Coder

Group Icon
Joined: 16 Oct, 2007
Posts: 1,967



Thanked 96 times

Dream Kudos: 475

Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua

My Contributions


Silly question, you sure you're closing the file you're writing to? When you're done reading, make sure you throw in a write.Close();.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 06:49AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month