aboutsummaryrefslogtreecommitdiff
path: root/day3.c
diff options
context:
space:
mode:
Diffstat (limited to 'day3.c')
-rw-r--r--day3.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/day3.c b/day3.c
index 00dca81..7179be6 100644
--- a/day3.c
+++ b/day3.c
@@ -11,10 +11,10 @@ int** make2dWithOffset(int rows, int cols, int roff, int coff) {
return (arr + roff);
}
-void free2dWithOffset(int** arr, int rows, int roff) {
+void free2dWithOffset(int** arr, int rows, int roff, int coff) {
int i;
for(i = -roff; i < rows - roff ; i++)
- free(arr[i]);
+ free(arr[i] - coff);
free(arr - roff);
}
@@ -79,6 +79,9 @@ int main() {
rssum++;
}
+ free2dWithOffset(somap, 400, 200, 200);
+ free2dWithOffset(rsmap, 400, 200, 200);
+
printf("Santa only: %d\nRobosanta: %d\n", sosum, rssum);
return 0;
}