aboutsummaryrefslogtreecommitdiff
path: root/stamping_the_grid.c
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-08-27 12:45:33 -0600
committerJack Sangdahl <[email protected]>2025-08-27 12:45:33 -0600
commit4552bcf5a4a356415e248dee3b201f0cea7205bb (patch)
tree9868465918c6a6841b84cd14d66923b993dd9d62 /stamping_the_grid.c
parentf549305fb5ca531d29dce6c2c091560f44190443 (diff)
downloadleetcode-4552bcf5a4a356415e248dee3b201f0cea7205bb.tar.gz
leetcode-4552bcf5a4a356415e248dee3b201f0cea7205bb.zip
chore: Refactor two_d_arr_init function
Return a pointer to a new struct, rather than initialise objects in an existing struct
Diffstat (limited to 'stamping_the_grid.c')
-rw-r--r--stamping_the_grid.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/stamping_the_grid.c b/stamping_the_grid.c
index e874acc..f2f25eb 100644
--- a/stamping_the_grid.c
+++ b/stamping_the_grid.c
@@ -77,13 +77,14 @@ int main() {
int g1i[6][4] = {
{1, 0, 0, 0}, {1, 0, 0, 0}, {1, 0, 0, 0}, {1, 0, 0, 0}, {1, 0, 0, 0}};
int g2i[4][4] = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
- struct two_d_arr g1, g2;
- two_d_arr_init(&g1, ARRAY_SIZE(g1i), ARRAY_SIZE(g1i[0]), g1i);
- two_d_arr_init(&g2, ARRAY_SIZE(g2i), ARRAY_SIZE(g2i[0]), g2i);
- printf("%d\n",
- possibleToStamp(g1.arr, g1.row_size, g1.col_size, 4, 3)); // expect: 1
- printf("%d\n",
- possibleToStamp(g2.arr, g2.row_size, g2.col_size, 2, 2)); // expect: 0
- two_d_arr_free(&g1);
- two_d_arr_free(&g2);
+ 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);
+ printf("%d\n", possibleToStamp(g1->arr, g1->row_size, g1->col_size, 4,
+ 3)); // expect: 1
+ printf("%d\n", possibleToStamp(g2->arr, g2->row_size, g2->col_size, 2,
+ 2)); // expect: 0
+ two_d_arr_free(g1);
+ two_d_arr_free(g2);
}