Kevin Behr

Greenhorn

Posts: 23

posted 9 years ago

Hello, I have two arrays:

Each array contains four colors (for the 2D array (board), each row contains four colors).

What I am looking to do is to compare the two arrays. I am looking to increment the integer variable 'none' for every color that exists in

board[][], but does not exist in useCode[].

Does anyone have any suggestions how I might accomplish this? So far, this is what I have:

I count how many times each color appears. But, since there are a total of six colors, and each array can only has four colors, I need a way to compare the two arrays...

I hope that makes sense, thanks for any help!

**useCode[]**and**board[][]**.Each array contains four colors (for the 2D array (board), each row contains four colors).

What I am looking to do is to compare the two arrays. I am looking to increment the integer variable 'none' for every color that exists in

board[][], but does not exist in useCode[].

Does anyone have any suggestions how I might accomplish this? So far, this is what I have:

I count how many times each color appears. But, since there are a total of six colors, and each array can only has four colors, I need a way to compare the two arrays...

I hope that makes sense, thanks for any help!

posted 9 years ago

When you say "for every color that exists in board[][]" do you mean exists in any of the rows in board? Or a specific row?

Can you elaborate on what you mean by "compare the two arrays". Since one is a two dimensional array, and the other is not, you can't directly compare the arrays. So they can never be "equal".

Are you trying to determine if a row array from the board 2D Array matches the useCode array in that they both have the same colors? And if so, do the four colors in each array need to be in the same order? Or just that each array contains the same colors? And then do you need to do that for each row?

I think it would be helpful to post more details about the problem. Perhaps post the full problem statement and directions. I think it will be easier then to point you in the right direction.

Also, just so we can guide you correctly... this sounds like it might be an assignment from a programming class. If so, do the directions explicitly state you must use arrays to solve the problem? Have you learned about other data collections yet?

I am looking to increment the integer variable 'none' for every color that exists in board[][], but does not exist in useCode[].

When you say "for every color that exists in board[][]" do you mean exists in any of the rows in board? Or a specific row?

I need a way to compare the two arrays

Can you elaborate on what you mean by "compare the two arrays". Since one is a two dimensional array, and the other is not, you can't directly compare the arrays. So they can never be "equal".

Are you trying to determine if a row array from the board 2D Array matches the useCode array in that they both have the same colors? And if so, do the four colors in each array need to be in the same order? Or just that each array contains the same colors? And then do you need to do that for each row?

I think it would be helpful to post more details about the problem. Perhaps post the full problem statement and directions. I think it will be easier then to point you in the right direction.

Also, just so we can guide you correctly... this sounds like it might be an assignment from a programming class. If so, do the directions explicitly state you must use arrays to solve the problem? Have you learned about other data collections yet?

It is sorta covered in the JavaRanch Style Guide. |