My input is a text document grid of 0's and 1's, which i then put into a two dimensional integer array.
The object for me is to "map" the 1's in the grid. I have to determine how many groups of 1's there are, how many each group has, and create a output text with the 1 groups labeled.
for example i receive the following in text:
1 0 1 0 0 1 0
1 1 1 0 1 1 0
1 0 0 0 1 0 0
0 0 1 0 0 0 1
0 0 1 1 1 1 1
I would have three total groups, then have to spit it out like:
1 0 1 0 0 2 0
1 1 1 0 2 2 0
1 0 0 0 2 0 0
0 0 3 0 0 0 3
0 0 3 3 3 3 3
As I'm doing my recursion, I created a two dimensional integer ArrayList to be expandable to groups and group members. I thought before that if i just changed all the "members" of the second group to 2's, then they should change in the original two dimensional Array because arrays are passed by reference.
Am I wrong? Let me know if any additional information needs to be given too.
Thanks in advance.
Edit: if use the ArrayList.contains() function, it seems i have the problem that its looking if it contains an actual "1" not if it contains int[][] array[0][1] for example.
Thanks!