Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int[] getColumn(int[][] arr2D, int c)
- {
- int[] result = new int[arr2D.length];
- for(int i = 0; i < arr2D.length; i++)
- {
- result[i] = arr2D[i][c];
- }
- return result;
- }
- public static boolean isLatin(int[][] square)
- {
- boolean firstRow = false;
- boolean eachRow = true;
- boolean eachColumn = true;
- firstRow = !(containsDuplicates(square[0]));
- int counter = 0;
- while(eachRow && counter < square[0].length)
- {
- if(!(hasAllValues(square[0], square[i])))
- {
- eachRow = false;
- }
- counter++;
- }
- counter = 0;
- while(eachColumn && counter < getColumn(square, 0))
- {
- if(!(hasAllValues(square[0], getColumn(square, i))))
- {
- eachColumn = false;
- }
- }
- return firstRow && eachRow && eachColumn;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement