Overview
| Comment: | day 5, part 1 |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
01755d413562cf8ed787359081fcc996 |
| User & Date: | nnz on 2025-12-05 12:16:14.784 |
| Other Links: | manifest | tags |
Context
|
2025-12-05
| ||
| 20:55 | incomplete attempt at day 5, part 2 check-in: 48d82159c3 user: nnz tags: trunk | |
| 12:16 | day 5, part 1 check-in: 01755d4135 user: nnz tags: trunk | |
|
2025-12-04
| ||
| 21:50 | reworked a few comments check-in: 12cb9a19a0 user: nnz tags: trunk | |
Changes
Modified aoc2025.c
from [6a6a951f89]
to [96f9068e94].
| ︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#if 0
/* === aocYYYYDD =======================================================
===================================================================== */
void aocYYYYDD(char *data, size_t len) {
(void)len; // unused argument
}
#endif
/* === aoc202504 =======================================================
===================================================================== */
static unsigned evolve(struct RectangularMap *rm, unsigned src) {
unsigned changes = 0;
unsigned dst = 1 - src;
for (int row = 0; row < rm->rows; row++) {
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
#if 0
/* === aocYYYYDD =======================================================
===================================================================== */
void aocYYYYDD(char *data, size_t len) {
(void)len; // unused argument
}
#endif
/* === aoc202505 =======================================================
===================================================================== */
struct Range {
long long unsigned lo, hi;
};
void aoc202505(char *data, size_t len) {
(void)len; // unused argument
struct Range r[200] = {0};
size_t nr = 0;
char *err;
for (;;) {
char *minus = strchr(data, '-');
if (!minus) break;
*minus = 0;
r[nr].lo = strtoull(data, &err, 10);
*minus++ = '-';
char *enter = strchr(minus, '\n');
*enter = 0;
r[nr++].hi = strtoull(minus, &err, 10);
*enter++ = '\n';
data = enter;
}
unsigned fresh = 0;
for (;;) {
long long unsigned item = strtoull(data, &err, 10);
if (err[0] != '\n') break;
if (item == 0) break;
data = err + 1;
for (size_t k = 0; k < nr; k++) {
if ((r[k].lo <= item) && (item <= r[k].hi)) {
fresh++;
break;
}
}
}
printf("There are %u fresh items.\n", fresh);
// pause for brain storming pause
}
/* === aoc202504 =======================================================
===================================================================== */
static unsigned evolve(struct RectangularMap *rm, unsigned src) {
unsigned changes = 0;
unsigned dst = 1 - src;
for (int row = 0; row < rm->rows; row++) {
|
| ︙ | ︙ |
Modified aocdailies.c
from [d8f37a577d]
to [7faacf4978].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include <stddef.h>
#include "aocdailies.h"
aocfunc *aocselect(unsigned y, unsigned d) {
aocfunc *p;
switch (y * 100 + d) {
default: p = NULL; break;
case 202504: p = aoc202504; break;
case 202503: p = aoc202503; break;
case 202502: p = aoc202502; break;
case 202501: p = aoc202501; break;
// YYYYdd ==> aocYYYYdd
case 202422: p = aoc202422; break;
| > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include <stddef.h>
#include "aocdailies.h"
aocfunc *aocselect(unsigned y, unsigned d) {
aocfunc *p;
switch (y * 100 + d) {
default: p = NULL; break;
case 202505: p = aoc202505; break;
case 202504: p = aoc202504; break;
case 202503: p = aoc202503; break;
case 202502: p = aoc202502; break;
case 202501: p = aoc202501; break;
// YYYYdd ==> aocYYYYdd
case 202422: p = aoc202422; break;
|
| ︙ | ︙ |
Modified aocdailies.h
from [39dda2d12a]
to [ede2fa7e92].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #ifndef AOCDAILIES_H_INCLUDED #define AOCDAILIES_H_INCLUDED #include <stddef.h> typedef void aocfunc(char *, size_t); aocfunc *aocselect(unsigned, unsigned); aocfunc aoc202504; aocfunc aoc202503; aocfunc aoc202502; aocfunc aoc202501; aocfunc aoc202422; aocfunc aoc202417; | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #ifndef AOCDAILIES_H_INCLUDED #define AOCDAILIES_H_INCLUDED #include <stddef.h> typedef void aocfunc(char *, size_t); aocfunc *aocselect(unsigned, unsigned); aocfunc aoc202505; aocfunc aoc202504; aocfunc aoc202503; aocfunc aoc202502; aocfunc aoc202501; aocfunc aoc202422; aocfunc aoc202417; |
| ︙ | ︙ |