Advent of Code

Check-in [94e59cac7b]
Login

Check-in [94e59cac7b]

Overview
Comment:201502 1st star
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 94e59cac7b3a297fe7074d33fb3c46e829c2e4fdbab28efe98befb68fc93c4f3
User & Date: nnz on 2024-12-04 14:49:01
Original Comment: 201502 1 star
Other Links: manifest | tags
Context
2024-12-04
14:54
201502 2nd star check-in: bae6237007 user: nnz tags: trunk
14:49
201502 1st star check-in: 94e59cac7b user: nnz tags: trunk
14:35
201501 2nd star check-in: 52ef9f6ef4 user: nnz tags: trunk
Changes

Modified aoc2015.c from [16ef74232c] to [d0e384f8d3].

1

2






















3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







#include <stdio.h>
#include <stdlib.h>
#include "aocdailies.h"
#include "aocutils.h"

void aoc201502(char *data, size_t len) {
    (void)len; // unused argument
    unsigned sqf = 0;
    for (;;) {
        char *err;
        unsigned l = strtoul(data, &err, 10);
        if (*err == 0) break;
        data = err + 1; // skip 'x'
        unsigned w = strtoul(data, &err, 10);
        data = err + 1; // skip 'x'
        unsigned h = strtoul(data, &err, 10);
        data = err + 1; // skip newline
        unsigned lw = l * w;
        unsigned wh = w * h;
        unsigned hl = h * l;
        unsigned m = min3u(lw, wh, hl);
        sqf += 2*(lw + wh + hl) + m;
    }
    printf("The elves need %u square feet of paper.\n", sqf);
}

void aoc201501(char *data, size_t len) {
    (void)len; // unused argument
    int floor = 0, basementsteps = -1;
    char *ddata = data;                            // save start
    while (*data) {
        if (*data == '(') floor++;

Modified aocdailies.c from [a1b4ea9d7f] to [439033dc50].

31
32
33
34
35
36
37
38
39

40
41
42
43
44
31
32
33
34
35
36
37

38
39
40
41
42
43
44







-

+





        case 201509: p = aoc201509; break;
        case 201508: p = aoc201508; break;
        case 201507: p = aoc201507; break;
        case 201506: p = aoc201506; break;
        case 201505: p = aoc201505; break;
        case 201504: p = aoc201504; break;
        case 201503: p = aoc201503; break;
        case 201502: p = aoc201502; break;
        #endif
        case 201502: p = aoc201502; break;
        case 201501: p = aoc201501; break;

    }
    return p;
}

Modified aocdailies.h from [3f62e57cfb] to [86e7c68c5a].

31
32
33
34
35
36
37
38
39

40
41
42
31
32
33
34
35
36
37

38
39
40
41
42







-

+



aocfunc aoc201509;
aocfunc aoc201508;
aocfunc aoc201507;
aocfunc aoc201506;
aocfunc aoc201505;
aocfunc aoc201504;
aocfunc aoc201503;
aocfunc aoc201502;
#endif
aocfunc aoc201502;
aocfunc aoc201501;

#endif