Overview
Comment: | 201502 2nd star |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
bae6237007a6e52b5b0c60d84c7b15bb |
User & Date: | nnz on 2024-12-04 14:54:13 |
Original Comment: | 201502 -- 2 stars |
Other Links: | manifest | tags |
Context
2024-12-04
| ||
15:15 | added to the ignore glob check-in: 9bfa42bf5d user: nnz tags: trunk | |
14:54 | 201502 2nd star check-in: bae6237007 user: nnz tags: trunk | |
14:49 | 201502 1st star check-in: 94e59cac7b user: nnz tags: trunk | |
Changes
Modified aoc2015.c from [d0e384f8d3] to [6413bdc5b2].
1 2 3 4 5 6 7 | #include <stdio.h> #include <stdlib.h> #include "aocdailies.h" #include "aocutils.h" void aoc201502(char *data, size_t len) { (void)len; // unused argument | | > > > > | 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 33 34 35 | #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, f = 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; unsigned M = max3u(l, w, h); unsigned feet = 2*(l+w+h - M) + l*h*w; f += feet; } printf("The elves need %u square feet of paper.\n", sqf); printf("The elves need %u feet of ribbon.\n", f); } void aoc201501(char *data, size_t len) { (void)len; // unused argument int floor = 0, basementsteps = -1; char *ddata = data; // save start while (*data) { |
︙ | ︙ |