Overview
Comment: | 202422 1st star |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
8769d8509e9d18b020e93d241e1709d8 |
User & Date: | nnz on 2024-12-25 15:31:46 |
Other Links: | manifest | tags |
Context
2024-12-26
| ||
11:56 | 202417 1st star check-in: acf723019c user: nnz tags: trunk | |
2024-12-25
| ||
15:31 | 202422 1st star check-in: 8769d8509e user: nnz tags: trunk | |
2024-12-15
| ||
16:42 | 201506 2nd star check-in: 9aa8be0d39 user: nnz tags: trunk | |
Changes
Modified aoc2024.c from [1416b27373] to [e64fb4bd5d].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include <ctype.h> #include <stdbool.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "aocdailies.h" #include "aocutils.h" /* === aoc202409 ======================================================= WOW! input consists of a 20,000 long string of numbers! Make an array of blocks, each with either -1 or the fileid For Part Two: make an array of blocks with the encoded value of (fileid * 10) + length, or, when empty, the negative length ===================================================================== */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 36 37 38 39 40 41 42 43 44 | #include <ctype.h> #include <stdbool.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "aocdailies.h" #include "aocutils.h" /* === aoc202422 ======================================================= ===================================================================== */ static long long unsigned mix(long long unsigned a, long long unsigned b) { long long unsigned tmp = a ^ b; return tmp; } static long long unsigned prune(long long unsigned a) { return a % 16777216; } void aoc202422(char *data, size_t len) { (void)len; // unused argument long long unsigned sum2000 = 0; char *key = strtok(data, "\n"); while (key) { long long unsigned secret; if (sscanf(key, "%llu", &secret) != 1) break; for (int k = 0; k < 2000; k++) { secret = prune(mix(secret * 64, secret)); secret = prune(mix(secret / 32, secret)); secret = prune(mix(secret * 2048, secret)); } sum2000 += secret; key = strtok(NULL, "\n"); } printf("The sum of all 2000th secrets is {%llu}.\n", sum2000); } /* === aoc202409 ======================================================= WOW! input consists of a 20,000 long string of numbers! Make an array of blocks, each with either -1 or the fileid For Part Two: make an array of blocks with the encoded value of (fileid * 10) + length, or, when empty, the negative length ===================================================================== */ |
︙ | ︙ |
Modified aocdailies.c from [6a934371b2] to [569de5a694].
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; // YYYYdd ==> aocYYYYdd case 202409: p = aoc202409; break; case 202408: p = aoc202408; break; case 202407: p = aoc202407; break; case 202406: p = aoc202406; break; case 202405: p = aoc202405; break; case 202404: p = aoc202404; break; case 202403: p = aoc202403; break; | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <stddef.h> #include "aocdailies.h" aocfunc *aocselect(unsigned y, unsigned d) { aocfunc *p; switch (y * 100 + d) { default: p = NULL; break; // YYYYdd ==> aocYYYYdd case 202422: p = aoc202422; break; case 202409: p = aoc202409; break; case 202408: p = aoc202408; break; case 202407: p = aoc202407; break; case 202406: p = aoc202406; break; case 202405: p = aoc202405; break; case 202404: p = aoc202404; break; case 202403: p = aoc202403; break; |
︙ | ︙ |
Modified aocdailies.h from [9f91169762] to [e496b7058b].
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 aoc202409; aocfunc aoc202408; aocfunc aoc202407; aocfunc aoc202406; aocfunc aoc202405; aocfunc aoc202404; aocfunc aoc202403; | > | 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 aoc202422; aocfunc aoc202409; aocfunc aoc202408; aocfunc aoc202407; aocfunc aoc202406; aocfunc aoc202405; aocfunc aoc202404; aocfunc aoc202403; |
︙ | ︙ |