Index: aoc2025.c ================================================================== --- aoc2025.c +++ aoc2025.c @@ -13,10 +13,53 @@ void aocYYYYDD(char *data, size_t len) { (void)len; // unused argument } #endif + +/* === aoc202507 ======================================================= +===================================================================== */ +static unsigned tachyon_splits(struct RectangularMap *rm) { + unsigned count = 0; + for (int row = 0; row < rm->rows; row++) { + for (int col = 0; col < rm->cols; col++) { + char cc = RMcharat(rm, col, row); + if ((cc == 'S') || (cc == '|')) { + char *pc = RMcharptr(rm, col, row+1); + if (pc == NULL) continue; + if (*pc == '.') { + *pc = '|'; + } else if (*pc == '^') { + *(pc - 1) = *(pc + 1) = '|'; + count++; + } else if (*pc == '|') { + /* do nothing */ + } else { + /* do nothing */ + } + } + } + } + return count; +} + +void aoc202507(char *data, size_t len) { + (void)len; // unused argument + struct RectangularMap rm[2] = {0}; + while (*data) { // copy from data to rms + char *data2 = data; + while (*data != '\n') data++; + *data = 0; // erase newline + RMaddline(rm + 0, data2); + RMaddline(rm + 1, data2); // set both rm's to the same thing + *data++ = '\n'; // unerase newline (obviously!) and skip it + } + unsigned part1 = tachyon_splits(rm); + printf("P1: %u\n", part1); + RMfree(rm); + RMfree(rm + 1); +} /* === aoc202506 ======================================================= ===================================================================== */ static long long unsigned add2506(long long unsigned v[4][1024], int lin, int col) { long long unsigned sum = 0; Index: aocdailies.c ================================================================== --- aocdailies.c +++ aocdailies.c @@ -4,10 +4,11 @@ aocfunc *aocselect(unsigned y, unsigned d) { aocfunc *p; switch (y * 100 + d) { default: p = NULL; break; + case 202507: p = aoc202507; break; case 202506: p = aoc202506; break; case 202505: p = aoc202505; break; case 202504: p = aoc202504; break; case 202503: p = aoc202503; break; case 202502: p = aoc202502; break; Index: aocdailies.h ================================================================== --- aocdailies.h +++ aocdailies.h @@ -4,10 +4,11 @@ #include typedef void aocfunc(char *, size_t); aocfunc *aocselect(unsigned, unsigned); +aocfunc aoc202507; aocfunc aoc202506; aocfunc aoc202505; aocfunc aoc202504; aocfunc aoc202503; aocfunc aoc202502;