Advent of Code

Check-in [12cb9a19a0]
Login

Check-in [12cb9a19a0]

Overview
Comment:reworked a few comments
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 12cb9a19a00f3012ae9999190e74bae6dcf8c0ba7fe4e7c859af65e212755234
User & Date: nnz on 2025-12-04 21:50:04.713
Other Links: manifest | tags
Context
2025-12-05
12:16
day 5, part 1 check-in: 01755d4135 user: nnz tags: trunk
2025-12-04
21:50
reworked a few comments check-in: 12cb9a19a0 user: nnz tags: trunk
21:34
day 4 check-in: 53ddcc2ade user: nnz tags: trunk
Changes
Modified aoc2025.c from [69ff078f3b] to [6a6a951f89].
38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53
54
55

56
57
58
59
60
61

62
63
64
65
66
67
68
69



70
71
72
73
74
75
76
38
39
40
41
42
43
44

45
46
47
48
49
50
51
52
53
54

55
56
57
58
59
60

61
62
63
64
65
66



67
68
69
70
71
72
73
74
75
76







-
+









-
+





-
+





-
-
-
+
+
+







                    changes++;
                } else {
                    *destin = '@';
                }
            } else if (cc != 0) {
                *destin = '.';
            } else {
                *destin = 0; // shouldn't happen
                *destin = 0; // shouldn't happen, except beyond borders
            }
        }
    }
    return changes;
}

void aoc202504(char *data, size_t len) {
    (void)len; // unused argument
    struct RectangularMap rm[2] = {0};
    while (*data) {
    while (*data) {                      // copy from data to rms
        char *data2 = data;
        while (*data != '\n') data++;
        *data = 0; // erase newline
        RMaddline(rm + 0, data2);
        RMaddline(rm + 1, data2); // set both rm's to the same thing
        *data++ = '\n'; // unerase newline and skip it
        *data++ = '\n'; // unerase newline (obviously!) and skip it
    }
    unsigned part1 = evolve(rm, 0); // evolve from rm[0] to rm[1]
    unsigned part2 = part1, src = 1;
    for (;;) {
        unsigned tmp = evolve(rm, src); // keep evolving
        if (tmp == 0) break; // STOP
        src = 1 - src;                  // back and forth
        part2 += tmp; // add changes in this round
        if (tmp == 0) break; // STOP    // back and forth
        src = 1 - src;                  // between rm[1] and rm[0]
        part2 += tmp; // add changes from this round
    }
    printf("P1: %u; P2: %u\n", part1, part2);
    RMfree(rm);
    RMfree(rm + 1);
}

/* === aoc202503 =======================================================