Index: aoc2024.c ================================================================== --- aoc2024.c +++ aoc2024.c @@ -9,11 +9,11 @@ /* === aoc202407 ======================================================= Part one looks easy ===================================================================== */ -static bool canbetrue(unsigned v, unsigned *a, size_t n) { +static bool canbetrue(unsigned long long v, unsigned long long *a, size_t n) { // for startes let's assume no overflowing if (n == 1) return (v == *a); unsigned tmp = a[1]; a[1] = a[0] + tmp; if (canbetrue(v, a+1, n-1)) return true; @@ -23,26 +23,25 @@ return false; } void aoc202407(char *data, size_t len) { (void)len; // unused argument - unsigned calibrationtotal = 0; + unsigned long long calibrationtotal = 0; char *line = strtok(data, "\n"); - unsigned number[50], nnumber, maxn = 0; + unsigned long long number[50], nnumber; while (line) { char *err; - unsigned testvalue = strtoul(line, &err, 10); + unsigned long long testvalue = strtoull(line, &err, 10); err += 1; // skip ':' nnumber = 0; while (*err == ' ') { number[nnumber++] = strtoul(err, &err, 10); } if (canbetrue(testvalue, number, nnumber)) calibrationtotal += testvalue; - if (nnumber > maxn) { maxn = nnumber; printf("max: %u\n", maxn); } line = strtok(NULL, "\n"); } - printf("The calibration total is {%u}.\n", calibrationtotal); + printf("The calibration total is {%llu}.\n", calibrationtotal); } /* === aoc202406 ======================================================= Hmmm, I've done something like this already this year... on day 4 I need rcmap() moved to aocutils ... done; now it's called `linearize2d`