Advent of Code

Check-in [121c2825b4]
Login

Check-in [121c2825b4]

Overview
Comment:days 1, 2, and 3
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 121c2825b44dc77c40703f918e943590b76b244a5d5aa8fa08a9b112b1f37ff4
User & Date: nnz on 2025-12-03 15:34:51.559
Other Links: manifest | tags
Context
2025-12-03
15:37
file for 2025 check-in: e75425b15b user: nnz tags: trunk
15:34
days 1, 2, and 3 check-in: 121c2825b4 user: nnz tags: trunk
2025-01-12
17:28
brought 202422 down to under 10 minutes check-in: f0e101dfbf user: nnz tags: trunk
Changes
Modified aoc.c from [d6d5abcd14] to [ea039d3ffa].
1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
17









-
+







/* *********************************************************************
Repository: https://chiselapp.com/user/nnz/repository/AdventOfCode/index
********************************************************************* */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "aocdailies.h" // prototypes for all aocYYYYdd functions!
#include "aocutils.h"

#define MAX_YEAR 2024
#define MAX_YEAR 2025

int main(int argc, char **argv) {
    unsigned y = 0, d = 0;
    char dataname[99];
    if (argc >= 3) {
        char *err;
        y = strtoul(argv[1], &err, 10);
1
2
3
4
5
6
7




8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18







+
+
+
+







#include <stddef.h>
#include "aocdailies.h"

aocfunc *aocselect(unsigned y, unsigned d) {
    aocfunc *p;
    switch (y * 100 + d) {
        default: p = NULL; break;

        case 202503: p = aoc202503; break;
        case 202502: p = aoc202502; break;
        case 202501: p = aoc202501; break;

        //   YYYYdd ==>  aocYYYYdd
        case 202422: p = aoc202422; break;
        case 202417: p = aoc202417; break;
        case 202409: p = aoc202409; break;
        case 202408: p = aoc202408; break;
        case 202407: p = aoc202407; break;
1
2
3
4
5
6
7




8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18







+
+
+
+







#ifndef AOCDAILIES_H_INCLUDED
#define AOCDAILIES_H_INCLUDED

#include <stddef.h>

typedef void aocfunc(char *, size_t);
aocfunc *aocselect(unsigned, unsigned);

aocfunc aoc202503;
aocfunc aoc202502;
aocfunc aoc202501;

aocfunc aoc202422;
aocfunc aoc202417;
aocfunc aoc202409;
aocfunc aoc202408;
aocfunc aoc202407;
aocfunc aoc202406;
31
32
33
34
35
36
37






38
39
40
41
42
43
44
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50







+
+
+
+
+
+







                     uint32_t (*F)(uint32_t, uint32_t, uint32_t)) {
    uint32_t tmp = *a;
    tmp += F(b, c, d);
    tmp += k;
    tmp += t;
    *a = b + rotateleft(tmp, s);
}

long long unsigned upow(unsigned base, unsigned exponent) {
    long long unsigned result = 1;
    while (exponent--) result *= base;
    return result;
}

void md5mini(unsigned char *dstarr, const char *src) {
    // see https://www.ietf.org/rfc/rfc1321.txt
    static uint32_t T[64] = {0};
    if (T[0] == 0) {
        #if 0
        for (int p = 0; p < 64; p++) {
1
2
3
4
5
6
7
8
9


10
11
12
13
14
15
16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18









+
+







#ifndef AOCUTILS_H_INCLUDED
#define AOCUTILS_H_INCLUDED

#include <stdbool.h>

struct TextGrid {
    unsigned cols, rows;
    char *data; // may have '\n' at end of rows
};

long long unsigned upow(unsigned base, unsigned exponent);

void md5mini(unsigned char *dstarr, const char *src);

bool TGvalid(struct TextGrid *tg, unsigned col, unsigned row);
char *TGcharptr(struct TextGrid *tg, unsigned col, unsigned row);
unsigned TGcol(struct TextGrid *tg, char *p);
unsigned TGrow(struct TextGrid *tg, char *p);