Set the matrix size of a new piece to its minimum size #45

Merged
tonitch merged 3 commits from matrixMinimumSize into master 2023-05-11 20:08:40 +02:00
2 changed files with 40 additions and 0 deletions
Showing only changes of commit 8ec5a622d8 - Show all commits

View File

@ -36,4 +36,22 @@ public class Array{
}
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);
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));
}
}