advent2025

Advent of Code 2025 Solutions
git clone git://bsandro.tech/advent2025
Log | Files | Refs | LICENSE

commit c35d636d7943d13b0242a57b0ab219ef096bbf95
parent 0e66260d2c5bae93979118ec70d5eca78853c91a
Author: bsandro <email@bsandro.tech>
Date:   Fri, 12 Dec 2025 10:34:25 +0200

day12 fin

Diffstat:
Mday12.c | 33++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)

diff --git a/day12.c b/day12.c @@ -22,15 +22,6 @@ typedef struct { int req_l; } Region; -void print_present(Present p) { - for (int y=0;y<3;++y) { - for (int x=0;x<3;++x) { - putchar(p.shape[y][x]); - } - putchar('\n'); - } -} - int main(void) { Present presents[6] = {0}; int cur_present = 0; @@ -71,19 +62,19 @@ int main(void) { } } - /*for (int p=0;p<6;++p) { - printf("present %d:\n", p); - print_present(presents[p]); - putchar('\n'); - } - printf("regions: %d\n", regions_l); + // 7 is the rough estimate of 'condensed' shape, I just tried 9 and worked my way down + // test input has magic value of 8. + int rough_area = regions_l==3 ? 8 : 7; + int p1 = 0; for (int r=0;r<regions_l;++r) { - Region *reg = &regions[r]; - printf("----------\nregion %dx%d\n", reg->w, reg->h); - for (int i=0;i<reg->req_l;++i) { - printf("%2d", reg->req[i]); + Region reg = regions[r]; + int min_area = reg.w*reg.h; + int area = 0; + for (int i=0;i<reg.req_l;++i) { + area += reg.req[i] * rough_area; } - printf("\n"); - }*/ + if (area<min_area) p1++; + } + printf("p1: %d\n", p1); return 0; }