public static boolean isLatin(int[][] a) { boolean rightElementsOK = false; //check if element is too big boolean tooBig = false; for (int row = 1; row < a.length; row++) { for (int col = 0; col < a[row].length; col++) { if (a[row][col] <= (a.length * a.length)) { //good } else { tooBig = true; break; } } } int cant = 0; // Check for Doppelgänger boolean b = false; // Man braucht 4 for schleifen, diese vergleicht man dann und // cant ist ein duplicate counter // if cant > 1 ist in der letzten schleife! for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[0].length; j++) { for (int k = 0; k < a.length; k++) { for (int l = 0; l < a[0].length; l++) { if(a[i][j] == a[k][l]){ cant++; } } } if(cant > 1){ b = true; } cant=0; } } if(b==false&&tooBig==false){ rightElementsOK = true; } return rightElementsOK; }