Advent of Code

Check-in [7b791fa5ed]
Login

Check-in [7b791fa5ed]

Overview
Comment:2025, day 7, part 1
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7b791fa5ed94125b62f12a2bf4e20a0dbbffe718fa4132eef74bf30ae806aa61
User & Date: nnz on 2025-12-08 11:12:07.625
Other Links: manifest | tags
Context
2025-12-08
11:14
removed double rm check-in: 5718bd5370 user: nnz tags: trunk
11:12
2025, day 7, part 1 check-in: 7b791fa5ed user: nnz tags: trunk
2025-12-06
12:09
2025,6,1 check-in: 968127189e user: nnz tags: trunk
Changes
Modified aoc2025.c from [2a923d68eb] to [b18c3d1b41].
11
12
13
14
15
16
17











































18
19
20
21
22
23
24
/* === aocYYYYDD =======================================================
===================================================================== */
void aocYYYYDD(char *data, size_t len) {
    (void)len; // unused argument
}

#endif












































/* === aoc202506 =======================================================
===================================================================== */
static long long unsigned add2506(long long unsigned v[4][1024], int lin, int col) {
    long long unsigned sum = 0;
    for (int k = 0; k < lin; k++) sum += v[k][col];
    return sum;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
66
67
/* === aocYYYYDD =======================================================
===================================================================== */
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;
    for (int k = 0; k < lin; k++) sum += v[k][col];
    return sum;
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 202506: p = aoc202506; 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;









>







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 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;
        case 202501: p = aoc202501; break;

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 aoc202506;
aocfunc aoc202505;
aocfunc aoc202504;
aocfunc aoc202503;
aocfunc aoc202502;
aocfunc aoc202501;









>







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 aoc202507;
aocfunc aoc202506;
aocfunc aoc202505;
aocfunc aoc202504;
aocfunc aoc202503;
aocfunc aoc202502;
aocfunc aoc202501;