aspose file tools*
The moose likes Servlets and the fly likes findword problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "findword problem" Watch "findword problem" New topic
Author

findword problem

flim pc
Greenhorn

Joined: Aug 31, 2004
Posts: 3
My question pertains more to a c++ program than java.
I was wondering if anyone might be able to give me a hit as where to start. here is my issue. I am unsure how to start solving this problem. I thought about using recursion to search the matrix but i am kinda lost as how to start. I though i would begin by using the Knuth-Morris-Pratt string matching algorithm but just dont know where i should begin.

Input would be the Filename: wordfind.in

The input file consists of a square table and a list of words. A blank line follows the table and then the words to find, one per line.

This is a sample of what my file contains.

cenad
aatps
rnrpj
hello
wmneo

hello
apple
car
me
men
ran
woman

Output

Filename: wordfind.out

This is what I wish my program to do after the program is run:

hello (3, 0) E
apple (0, 3) S
car (0, 0) S
car (0, 0) SE
me (4, 1) N
men (4, 1) N
ran (2, 0) NE
woman NOT FOUND
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Hi Flim,

Welcome to JavaRanch!

Firstly, can I point out that the Servlets forum is not the place for your question as it appears to have nothing to do with Servlets. Also, you've posted it twice, so perhaps you could delete the other post.

I've no idea what the Knuth-Morris-Pratt thingy is, but I will try and give you a pointer to help you start solving your problem.

So you're writing a Word Search game (that's what we call it in the UK anyway). My tip is to think about how you would solve the problem without a computer. How would you find the word "men" in your grid, for example? Write the steps that you take to solve the problem down on paper. Then try to translate each of those steps into program code.

Once you get going if you find you need further help I would suggest that you post your query in one of the Java In General forums.

Hope that helps.

Jules
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

Please don't post the same thread in multiple forums, it makes the conversation difficult to follow.

I'm leaving the version in Programming Diversions, I think its a good fit for that forum. So please continue the discussion here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: findword problem