1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#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)data; // unused argument
(void)len; // unused argument
printf("wip/n");
}
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;
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
|
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;
|