Index: aoc2024.c ================================================================== --- aoc2024.c +++ aoc2024.c @@ -16,10 +16,15 @@ 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++) { @@ -47,10 +52,11 @@ } } } } printf("There are %u antinodes within the map.\n", nanti); + #endif } /* === aoc202407 ======================================================= Part one looks easy Part two also easy Index: aocutils.h ================================================================== --- aocutils.h +++ aocutils.h @@ -1,7 +1,9 @@ #ifndef AOCUTILS_H_INCLUDED #define AOCUTILS_H_INCLUDED + +#include struct TextGrid { unsigned rows, cols; char *data; // may have '\n' at end of rows };