https://www.codechef.com/JUNE20B/problems/EVENM

I have written a solution which is divided into two parts

- One is for when N is odd which is essentially just filling the matrix with consecutive numbers 1 to N^2
- When N is even I have just generated a spiral matrix that goes in the clockwise direction.

Here is the solution https://www.codechef.com/viewsolution/34390953

I had also written a function to check my solution against the conditions given.

```
private static boolean checkMatrix(int[][] matrix) {
int a = 0;
int n = matrix.length;
for (; a < n; a++) {
for (int j = 0; j < n; j++) {
for (int k = 0; k < n; k++) {
if( !(j + a >= n || k + a >= n) ) {
if((matrix[j][k] + matrix[j+a][k+a]) % 2 == 1) {
return false;
}else if((matrix[j+a][k] + matrix[j][k+a]) % 2 == 1) {
return false;
}
}
}
}
}
return true;
}
```

Can someone please help me understand the flaws in my logic