Advent of Code

Diff
Login

Diff

Differences From Artifact [d0e384f8d3]:

To Artifact [6413bdc5b2]:


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
#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) {







|














>
>
>


>







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) {