Overview
Comment: | 201506 1st star |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
e9f61cfc4a570c933afa05af5aacc0d3 |
User & Date: | nnz on 2024-12-15 15:51:21 |
Other Links: | manifest | tags |
Context
2024-12-15
| ||
16:42 | 201506 2nd star check-in: 9aa8be0d39 user: nnz tags: trunk | |
15:51 | 201506 1st star check-in: e9f61cfc4a user: nnz tags: trunk | |
13:12 | 201505 reworked my solution check-in: 02e370e22c user: nnz tags: trunk | |
Changes
Modified aoc2015.c from [0dc60fd2e9] to [3e3bef2904].
1 2 3 4 5 6 7 8 9 10 11 12 13 | #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "aocdailies.h" #include "aocutils.h" void aoc201505(char *data, size_t len) { (void)len; // unused argument unsigned nice = 0, nice2 = 0; char *line = strtok(data, "\n"), *curr; while (line) { unsigned vowels = 0; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 45 46 47 48 49 50 51 52 53 54 | #include <ctype.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "aocdailies.h" #include "aocutils.h" static void gridchange(bool *grid, int v, unsigned r1, unsigned c1, unsigned r2, unsigned c2) { unsigned firstrow = (r1 < r2) ? r1 : r2; unsigned lastrow = (r1 < r2) ? r2 : r1; unsigned firstcol = (c1 < c2) ? c1 : c2; unsigned lastcol = (c1 < c2) ? c2 : c1; for (unsigned row = firstrow; row <= lastrow; row++) { for (unsigned col = firstcol; col <= lastcol; col++) { grid[1000*row + col] = (v < 0) ? !grid[1000*row + col] : !!v; } } } void aoc201506(char *data, size_t len) { (void)len; // unused argument bool *grid_ptr = calloc(1000 * 1000, 1); char *line = strtok(data, "\n"); while (line) { unsigned x1, x2, y1, y2; char *err = line; while (!isdigit((unsigned char)*err)) err++; y1 = strtoul(err, &err, 10); err++; x1 = strtoul(err, &err, 10); while (!isdigit((unsigned char)*err)) err++; y2 = strtoul(err, &err, 10); err++; x2 = strtoul(err, &err, 10); if (line[6] == 'n') gridchange(grid_ptr, 1, y1, x1, y2, x2); if (line[6] == 'f') gridchange(grid_ptr, 0, y1, x1, y2, x2); if (line[6] == ' ') gridchange(grid_ptr, -1, y1, x1, y2, x2); line = strtok(NULL, "\n"); } unsigned lit = 0; for (unsigned row = 0; row < 1000; row++) { for (unsigned col = 0; col < 1000; col++) { lit += grid_ptr[1000*row + col]; } } free(grid_ptr); printf("After following the instructions, there are %u lights lit.\n", lit); } void aoc201505(char *data, size_t len) { (void)len; // unused argument unsigned nice = 0, nice2 = 0; char *line = strtok(data, "\n"), *curr; while (line) { unsigned vowels = 0; |
︙ | ︙ |
Modified aocdailies.c from [f37c08030f] to [6a934371b2].
︙ | ︙ | |||
33 34 35 36 37 38 39 | case 201513: p = aoc201513; break; case 201512: p = aoc201512; break; case 201511: p = aoc201511; break; case 201510: p = aoc201510; break; case 201509: p = aoc201509; break; case 201508: p = aoc201508; break; case 201507: p = aoc201507; break; | < > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | case 201513: p = aoc201513; break; case 201512: p = aoc201512; break; case 201511: p = aoc201511; break; case 201510: p = aoc201510; break; case 201509: p = aoc201509; break; case 201508: p = aoc201508; break; case 201507: p = aoc201507; break; #endif case 201506: p = aoc201506; break; case 201505: p = aoc201505; break; case 201504: p = aoc201504; break; case 201503: p = aoc201503; break; case 201502: p = aoc201502; break; case 201501: p = aoc201501; break; } |
︙ | ︙ |
Modified aocdailies.h from [3ea2baaa69] to [9f91169762].
︙ | ︙ | |||
32 33 34 35 36 37 38 | aocfunc aoc201513; aocfunc aoc201512; aocfunc aoc201511; aocfunc aoc201510; aocfunc aoc201509; aocfunc aoc201508; aocfunc aoc201507; | < > | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | aocfunc aoc201513; aocfunc aoc201512; aocfunc aoc201511; aocfunc aoc201510; aocfunc aoc201509; aocfunc aoc201508; aocfunc aoc201507; #endif aocfunc aoc201506; aocfunc aoc201505; aocfunc aoc201504; aocfunc aoc201503; aocfunc aoc201502; aocfunc aoc201501; #endif |