This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

2D array: Find an array of characters

 
Scotty Young
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on a problem to help try and improve my java skills before I sit SCJA:

I have an array, "word", with three characters "D" "O" and "G".

I'm trying to search through a larger 2D array and then print out all three characters when they are matched in a row.

I have worked this out on a white board with someone before, but I cant remember how I solved it... derp.

This is the code I currently have:


I feel like I'm close to solving it.>
 
Greg Brannon
Bartender
Posts: 563
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How close? What's your program doing now? What should it be doing?
 
Scotty Young
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'm trying to get it to output DOG. At the minute its outputting DDODDDOG.

I thought I knew what I was doing but now I'm a bit lost and confused. I want it to compare every single character in square to the characters in word, and output the characters that match, but only if it finds them in the sequence D-O-G.
 
Carey Brown
Ranch Hand
Pie
Posts: 1073
11
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know we're not supposed to give out "answers" but I couldn't resist giving this a try. Works for any size 'square' and 'word'. Prints out list of square coordinates where 'd-o-g' was found.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic