Page 1 of 1

IN JAVA 10X10 TAKUZU CHECKER PROGRAM You should write a method public static boolean isSolutionValid(int[][] solution);

Posted: Wed Mar 30, 2022 9:28 am
by answerhappygod
IN JAVA 10X10 TAKUZU CHECKER PROGRAM
You should write a method public static boolean
isSolutionValid(int[][] solution); that checks whether the
matrix provided by solution is a valid Takuzu solution. It
should return true when the solution is valid and false otherwise.
You do not have to
check if the solution satisfies a given starting solution in this
case.
Hint:
Write separate methods to check certain conditions of the solution.
In particular, you
may want to create the following methods, that you can then use in
the
isSolutionValid method:
public static boolean checkAllOneOrZero(int[][] solution)
that checks if each value in the solution matrix is equal to 0
or 1.
public static int countNumberOfOnesInRow(int[][] solution, int
rowNumber)
to check the number of 1 values (ones) present in row rowNumber
of the solution
matrix.
public static int countNumberOfOnesInColumn(int[][] solution,
int colNumber)
to check the number of 1 values (ones) present in column
colNumber of the solution
matrix.
public static boolean checkConsecutivesForRow(int[][] solution,
int
rowNumber)
o check that there are no more than two consecutive zero or one
values in row
rowNumber of the solution matrix.
public static boolean checkConsecutivesForColumn(int[][]
solution, int
colNumber)
to check that there are no more than two consecutive zero or one
values in column
colNumber of the solution matrix.