Overview
Comment: | 202405 -- read first part of data |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
7cae0b9197023e0428bad2ac241b6460 |
User & Date: | nnz on 2024-12-05 11:12:58 |
Other Links: | manifest | tags |
Context
2024-12-05
| ||
11:14 | 202405 -- adjust array size check-in: 431fcb199e user: nnz tags: trunk | |
11:12 | 202405 -- read first part of data check-in: 7cae0b9197 user: nnz tags: trunk | |
10:53 | 202405 -- tiny mistake check-in: ab3c10d320 user: nnz tags: trunk | |
Changes
Modified aoc2024.c from [4fa15782cd] to [e65661e9bd].
1 2 3 4 5 6 7 8 9 10 | #include <ctype.h> #include <stdbool.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "aocdailies.h" #include "aocutils.h" void aoc202405(char *data, size_t len) { | < > > > > > > > > > > > > > | > > > | 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 <ctype.h> #include <stdbool.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "aocdailies.h" #include "aocutils.h" void aoc202405(char *data, size_t len) { (void)len; // unused argument // assume (by visual inspection) all page numbers `pn` are between 10 and 99 unsigned pagepair[2500][2], npp = 0; char *line = strtok(data, "\n"); while (strchr(line, '|')) { char *err; pagepair[npp][0] = strtoul(line, &err, 10); err += 1; // skip '|' pagepair[npp][1] = strtoul(line, &err, 10); npp++; line = strtok(NULL, "\n"); } printf("first pagepair: %u and %u\n", pagepair[0][0], pagepair[0][1]); printf("last pagepair: %u and %u\n", pagepair[npp - 1][0], pagepair[npp - 1][1]); printf("got %u pairs\n", npp); while ((line = strtok(NULL, "\n")) != NULL) { // process line } } static size_t rcmap(unsigned size, unsigned row, unsigned col) { return row * (size + 1) + col; } static bool masat(char *data, unsigned size, unsigned row, unsigned col, int drow, int dcol) { int maxrow = (int)row + 3*drow; |
︙ | ︙ |