isColumn/RowOnlyFalse

This commit is contained in:
Debucquoy Anthony 2023-05-10 20:22:20 +02:00
parent e7c7065a8d
commit 8ec5a622d8
Signed by: tonitch
GPG Key ID: A78D6421F083D42E
2 changed files with 40 additions and 0 deletions

View File

@ -36,4 +36,22 @@ public class Array{
} }
return newMatrix; return newMatrix;
} }
public static boolean isRowOnlyFalse(boolean[][] o, int row){
boolean mark = true;
for (int i = 0; i < o[row].length; i++) {
if(o[row][i])
mark = false;
}
return mark;
}
public static boolean isColumnOnlyFalse(boolean[][] o, int column){
boolean mark = true;
for (int i = 0; i < o.length; i++) {
if(o[i][column])
mark = false;
}
return mark;
}
} }

View File

@ -56,4 +56,26 @@ class ArrayTest {
boolean[][] result = Array.MatrixRemoveColumn(a, 1); boolean[][] result = Array.MatrixRemoveColumn(a, 1);
assertArrayEquals(b, result); assertArrayEquals(b, result);
} }
@Test
void isRowOnlyFalse() {
boolean[][] a = new boolean[][] {
{true, false, true},
{false, false, false},
{true, false, true},
};
assertTrue(Array.isRowOnlyFalse(a, 1));
assertFalse(Array.isRowOnlyFalse(a, 0));
}
@Test
void isColumnOnlyFalse() {
boolean[][] a = new boolean[][] {
{true, false, true},
{false, false, false},
{true, false, true},
};
assertTrue(Array.isColumnOnlyFalse(a, 1));
assertFalse(Array.isColumnOnlyFalse(a, 0));
}
} }