Advent of Code

Check-in [278fc62fcc]
Login

Check-in [278fc62fcc]

Overview
Comment:removed dead code
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 278fc62fcc4cf1988a6b144adf332333a5e087be356b62ccf26d960a908488e5
User & Date: nnz on 2024-12-07 13:52:08
Other Links: manifest | tags
Context
2024-12-07
14:37
fixed possible bug check-in: c6ad316f4d user: nnz tags: trunk
13:52
removed dead code check-in: 278fc62fcc user: nnz tags: trunk
13:50
reworked operators insertion logic check-in: 9237d89a9a user: nnz tags: trunk
Changes

Modified aoc2024.c from [98d4a70597] to [5ec424337a].

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
58
59
60
61
62
63
64








65
66
67
68
69
70
71







-
-
-
-
-
-
-
-







        switch (operatorsrequired(testvalue, number, nnumber, 0)) {
            default: break;
            case 2: calibrationtotal += testvalue;
                    __attribute__((fallthrough));
            case 3: calibration3total += testvalue;
                    break;
        }
        #if 0
        if (canbetrue(testvalue, number, nnumber)) {
            calibrationtotal += testvalue;
        }
        if (canbetrue3(testvalue, number, nnumber)) {
            calibration3total += testvalue;
        }
        #endif
        line = strtok(NULL, "\n");
    }
    printf("The calibration total is {%llu}.\n", calibrationtotal);
    printf("The calibration total with three operators is {%llu}.\n", calibration3total);
}

/* === aoc202406 =======================================================
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
274
275
276
277
278
279
280












281
282
283
284
285
286
287







-
-
-
-
-
-
-
-
-
-
-
-







    return (tmp == 15);
}

void aoc202404(char *data, size_t len) {
    (void)len; // unused argument
    // assume data is well-formatted and has the same number of rows and columns
    unsigned size = strchr(data, '\n') - data;
    #if 0 // check assumption
    printf("data has %u cols, first three rows start with %c%c, %c%c, and %c%c.\n",
          size, data[0], data[1],
          data[1*(size+1)], data[1*(size+1)+1],
          data[2*(size+1)], data[2*(size+1)+1]);
    printf("ends with %c%c.\n", data[(size-1)*(size+1) + size-2], data[(size-1)*(size+1)+size-1]);
    printf("data has %u cols, first three rows start with %c%c, %c%c, and %c%c.\n",
          size, data[linearize2d(size+1, 0, 0)], data[linearize2d(size+1, 0, 1)],
          data[linearize2d(size+1, 1, 0)], data[linearize2d(size+1, 1, 1)],
          data[linearize2d(size+1, 2, 0)], data[linearize2d(size+1, 2, 1)]);
    printf("ends with %c%c.\n", data[linearize2d(size+1, size-1, size-2)], data[linearize2d(size+1, size-1, size-1)]);
    #endif
    unsigned xmascount = 0, Xmascount = 0;
    for (unsigned row = 0; row < size; row++) {
        for (unsigned col = 0; col < size; col++) {
            xmascount += xmasat(data, size, row, col);
            if ((1 <= row) && (row < size - 1) && (1 <= col) && (col < size - 1)) {
                if (Xmasat(data, size, row, col)) Xmascount++;
            }