commit e09cdeb3b2598bad87838f49c124e90a6cd9c3e9
parent 6ae28ab4a88ede5b536e3f6625a08c249af4d562
Author: Jack Sangdahl <jack@pngu.org>
Date: Mon, 27 Apr 2026 20:56:36 -0600
2033. minimum operations to mak ea uni-value grid
Diffstat:
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/min_ops_uni_val_grid.c b/min_ops_uni_val_grid.c
@@ -31,20 +31,24 @@ int minOperations(int **grid, int gridSize, int *gridColSize, int x) {
}
int main() {
- int g1i[2][2] = {{2, 4}, {6, 8}}, g2i[2][2] = {{1, 5}, {2, 3}},
- g3i[2][2] = {{1, 2}, {3, 4}};
+ int g1i[2][2] = {{2, 4}, {6, 8}};
+ int g2i[2][2] = {{1, 5}, {2, 3}};
+ int g3i[2][2] = {{1, 2}, {3, 4}};
struct two_d_arr *g1 =
two_d_arr_init(ARRAY_SIZE(g1i), ARRAY_SIZE(g1i[0]), g1i);
struct two_d_arr *g2 =
two_d_arr_init(ARRAY_SIZE(g2i), ARRAY_SIZE(g2i[0]), g2i);
struct two_d_arr *g3 =
two_d_arr_init(ARRAY_SIZE(g3i), ARRAY_SIZE(g3i[0]), g3i);
- printf("%d\n",
- minOperations(g1->arr, g1->row_size, g1->col_size, 2)); // expect: 4
- printf("%d\n",
- minOperations(g2->arr, g2->row_size, g2->col_size, 1)); // expect: 5
- printf("%d\n",
- minOperations(g3->arr, g3->row_size, g3->col_size, 2)); // expect: -1
+ int r1 = minOperations(g1->arr, g1->row_size, g1->col_size, 2);
+ int r2 = minOperations(g2->arr, g2->row_size, g2->col_size, 1);
+ int r3 = minOperations(g3->arr, g3->row_size, g3->col_size, 2);
+ printf("%d\n", r1);
+ assert(r1 == 4);
+ printf("%d\n", r2);
+ assert(r2 == 5);
+ printf("%d\n", r3);
+ assert(r3 == -1);
two_d_arr_free(g1);
two_d_arr_free(g2);
two_d_arr_free(g3);