I can find consecutives in the same row as follow:
int count = 0;
for (int column = 0; column < list[currentRow].length; column++)
if (list[currentRow][column].equals(currentValue))
count++;
And consecutives in the same column as follow:
for (int row = currentRow; row < list.length; row++)
if (list[row][currentColumn].equals(currentValue))
count++;
How to find consecutives in the same diagonal?
My tries :
for (int majorDiagonal = currentRow + 1, column = currentColumn; majorDiagonal < list.length; majorDiagonal++, column++) {
if (list[majorDiagonal][column].equals(currentValue))
countMajorDiagonal++;
}
And:
for (int subDiagonal = 0; subDiagonal < list.length; subDiagonal++) {
if (list[subDiagonal][(list.length - subDiagonal) - 1].equals(currentValue))
countMajorSubDiagonal++;
}