Advent of Code

Diff
Login

Diff

Differences From Artifact [50f843a30c]:

To Artifact [89d3d4a8c3]:


14
15
16
17
18
19
20





21
22
23
24
25
26
27
and add the resulting points (if not there already) to an array.
   The answer to Part One is the number of elements in the array
TODO: I don't like my `linearize2d` thing! Thinking of a replacement
===================================================================== */

void aoc202408(char *data, size_t len) {
    (void)len; // unused argument





    unsigned anti[256][2]; // locations of antinodes
    unsigned nanti = 0;
    unsigned size = 1 + strchr(data, '\n') - data;
    for (unsigned row = 0; row < size-1; row++) {
        for (unsigned col = 0; col < size-1; col++) {
            char *p = data + linearize2d(size, row, col);
            if (*p != '.') {







>
>
>
>
>







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
and add the resulting points (if not there already) to an array.
   The answer to Part One is the number of elements in the array
TODO: I don't like my `linearize2d` thing! Thinking of a replacement
===================================================================== */

void aoc202408(char *data, size_t len) {
    (void)len; // unused argument
    struct TextGrid tg;
    tg.data = data;
    tg.cols = strchr(data, '\n') - data + 1;
    tg.rows = tg.cols - 1; // rows includes the '\n'
    #if 0
    unsigned anti[256][2]; // locations of antinodes
    unsigned nanti = 0;
    unsigned size = 1 + strchr(data, '\n') - data;
    for (unsigned row = 0; row < size-1; row++) {
        for (unsigned col = 0; col < size-1; col++) {
            char *p = data + linearize2d(size, row, col);
            if (*p != '.') {
45
46
47
48
49
50
51

52
53
54
55
56
57
58
                    }
                    q = strchr(q + 1, *p);
                }
            }
        }
    }
    printf("There are %u antinodes within the map.\n", nanti);

}

/* === aoc202407 =======================================================
   Part one looks easy
   Part two also easy
 ===================================================================== */








>







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
                    }
                    q = strchr(q + 1, *p);
                }
            }
        }
    }
    printf("There are %u antinodes within the map.\n", nanti);
    #endif
}

/* === aoc202407 =======================================================
   Part one looks easy
   Part two also easy
 ===================================================================== */