advent-of-code

advent of code attempts
git clone git://bvnf.space/advent-of-code.git
Log | Files | Refs

commit 6bd8091226007557b581f55137cdd17f2e494aea
parent 8c6397817e1394c23312dba7b6ba448206e81413
Author: aabacchus <ben@bvnf.space>
Date:   Fri,  9 Dec 2022 19:41:42 +0000

22.9 in C

avoiding globals really helped for part B

Diffstat:
A2022/09/a.c | 168+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2022/09/example | 8++++++++
A2022/09/input | 2000+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 2176 insertions(+), 0 deletions(-)

diff --git a/2022/09/a.c b/2022/09/a.c @@ -0,0 +1,168 @@ +#include <math.h> +#include <stdio.h> +#include <stdlib.h> + +#define ROPELEN 10 + +#define UP(head) ((head).y++) +#define DOWN(head) ((head).y--) +#define LEFT(head) ((head).x--) +#define RIGHT(head) ((head).x++) + +struct point { + long x, y; +}; + +struct visited { + size_t len; + struct point *p; +}; + +void * +emalloc(size_t size) { + void *p = calloc(size, 1); + if (p == NULL) { + perror("emalloc"); + exit(1); + } + return p; +} + +struct visited * +visited_init(void) { + struct visited *v; + v = emalloc(sizeof (struct visited)); + v->p = emalloc(sizeof (struct point)); + v->len = 1; + v->p[0].x = v->p[0].y = 0; + return v; +} + +void +visited_destroy(struct visited *v) { + if (v) { + free(v->p); + free(v); + } +} + +int +check_visited(struct point *p, struct visited *v) { + for (size_t i = 0; i < v->len; i++) { + if ((v->p[i].x == p->x) && + (v->p[i].y == p->y)) + return 1; + } + return 0; +} + +void +visit(struct point *tail, struct visited **v) { + if (check_visited(tail, *v) == 1) + return; + struct point *tmp = realloc((*v)->p, sizeof(struct point) * ((*v)->len + 1)); + if (tmp == NULL) { + free((*v)->p); + free(*v); + perror("realloc"); + exit(1); + } + tmp[(*v)->len].x = tail->x; + tmp[(*v)->len].y = tail->y; + (*v)->p = tmp; + (*v)->len++; + return; +} + +void +update_tail(struct point *h, struct point *t) { + long dx = h->x - t->x; + long dy = h->y - t->y; + double d = sqrt((dx * dx) + (dy * dy)); + if (d < 2.0) + return; + + if (h->x == t->x) { + t->y += h->y > t->y ? 1 : -1; + } else if (h->y == t->y) { + t->x += h->x > t->x ? 1 : -1; + } else { + t->x += h->x > t->x ? 1 : -1; + t->y += h->y > t->y ? 1 : -1; + } +} + +int +main(int argc, char **argv) { + char *buf = NULL; + size_t buflen = 0; + ssize_t n; + FILE *f; + + struct visited *v1, *v2; + struct point rope[ROPELEN] = {0}; + v1 = visited_init(); + v2 = visited_init(); + + if (argc != 2) { + fprintf(stderr, "usage: %s input\n", argv[0]); + return 1; + } + + f = fopen(argv[1], "r"); + if (f == NULL) { + perror(argv[1]); + return 1; + } + + while ((n = getline(&buf, &buflen, f)) != -1) { + if (buf[n - 1] == '\n') { + buf[n - 1] = '\0'; + n--; + } + int num; + if (sscanf(buf+2, "%d", &num) != 1) { + perror("sscanf"); + return 1; + } + for (int i = 0; i < num; i++) { + switch (buf[0]) { + case 'U': + UP(rope[0]); + break; + case 'D': + DOWN(rope[0]); + break; + case 'L': + LEFT(rope[0]); + break; + case 'R': + RIGHT(rope[0]); + break; + default: + fprintf(stderr, "unknown command \"%s\"\n", buf); + return 1; + } + + for (size_t i = 1; i < ROPELEN; i++) + update_tail(&rope[i - 1], &rope[i]); + + /* Keep track of the knot immediately after the head (A), and the last knot (B). */ + visit(&rope[1], &v1); + visit(&rope[ROPELEN-1], &v2); + } + } + + printf( "Part A: %ld\n" + "Part B: %ld\n", + v1->len, + v2->len); + + visited_destroy(v1); + visited_destroy(v2); + + free(buf); + fclose(f); + + return 0; +} diff --git a/2022/09/example b/2022/09/example @@ -0,0 +1,8 @@ +R 4 +U 4 +L 3 +D 1 +R 4 +D 1 +L 5 +R 2 diff --git a/2022/09/input b/2022/09/input @@ -0,0 +1,2000 @@ +R 2 +D 2 +U 1 +D 2 +U 2 +R 2 +U 2 +R 2 +L 2 +D 2 +R 1 +D 2 +R 1 +L 1 +R 2 +U 1 +R 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+R 14 +L 10 +U 13 +L 16 +R 15 +L 12 +U 10 +L 2 +D 8 +L 7 +D 16 +L 17 +U 16 +R 13 +D 6 +U 8 +L 13 +D 9 +U 13 +D 3 +R 1 +U 12 +D 6 +L 8 +U 15 +R 6 +L 14 +U 15 +D 4 +U 9 +R 6 +D 8 +L 10 +D 3 +R 12 +L 10 +R 2 +D 2 +U 17 +D 16 +R 5 +L 13 +R 12 +L 4 +U 4 +L 12 +U 3 +L 15 +U 10 +L 5 +U 2 +D 13 +R 10 +U 7 +R 9 +D 7 +R 12 +U 14 +L 7 +R 10 +D 11 +U 8 +L 5 +R 4 +U 17 +L 12 +R 6 +L 17 +D 11 +R 17 +U 1 +D 2 +U 14 +D 17 +L 2 +D 14 +R 14 +L 1 +U 5 +D 8 +U 1 +R 12 +U 8 +D 3 +L 1 +D 8 +R 5 +U 9 +D 13 +U 15 +D 3 +R 15 +L 2 +R 2 +U 8 +R 1 +L 17 +U 16 +L 10 +D 2 +R 6 +L 11 +D 14 +R 3 +L 15 +U 16 +R 12 +U 1 +D 2 +U 2 +R 7 +L 4 +D 12 +U 12 +L 12 +U 15 +R 4 +U 8 +R 12 +L 5 +R 3 +L 5 +R 18 +L 4 +D 14 +R 4 +L 17 +R 18 +U 9 +D 18 +R 4 +U 13 +R 3 +D 6 +R 15 +L 1 +U 5 +L 3 +U 2 +R 15 +U 8 +L 7 +D 9 +L 15 +U 13 +L 17 +D 17 +R 15 +D 15 +L 14 +D 15 +R 16 +U 3 +D 6 +L 1 +R 14 +U 16 +L 7 +U 2 +L 14 +D 5 +L 6 +D 12 +R 18 +U 16 +D 7 +L 18 +D 10 +R 1 +L 8 +R 16 +L 5 +U 4 +R 18 +D 18 +R 5 +D 10 +L 18 +R 8 +L 2 +R 13 +L 16 +D 16 +U 17 +L 2 +R 5 +L 12 +D 10 +L 10 +D 6 +R 12 +L 17 +R 8 +L 14 +R 15 +L 18 +D 5 +R 1 +L 8 +U 13 +R 9 +U 14 +L 18 +U 4 +D 16 +L 7 +U 16 +L 14 +D 18 +R 1 +D 2 +R 11 +D 3 +U 12 +D 11 +U 2 +L 12 +U 7 +D 2 +R 8 +D 1 +U 9 +L 5 +D 14 +L 9 +D 5 +L 18 +D 16 +U 3 +R 13 +D 16 +R 18 +D 10 +L 4 +R 2 +L 5 +D 13 +L 15 +U 16 +R 9 +D 15 +R 5 +L 3 +U 5 +R 10 +U 3 +L 11 +R 14 +L 4 +D 7 +R 11 +D 12 +L 14 +R 13 +U 15 +R 14 +D 2 +R 16 +U 3 +D 3 +L 17 +D 11 +U 10 +L 2 +U 12 +D 3 +L 5 +D 9 +U 7 +D 14 +R 5 +L 14 +D 3 +R 11 +L 17 +U 7 +L 8 +U 2 +R 3 +D 18 +L 16 +U 12 +D 16 +R 6 +U 16 +D 10 +R 1 +L 7 +U 18 +R 2 +U 13 +R 15 +D 1 +R 15 +D 9 +U 9 +R 15 +D 6 +L 14 +D 15 +R 15 +D 10 +U 15 +L 17 +D 12 +R 6 +L 1 +R 15 +L 7 +D 11 +R 12 +D 9 +L 17 +D 18 +L 19 +D 2 +L 9 +D 1 +L 7 +R 5 +L 5 +R 1 +D 2 +L 1 +U 19 +L 5 +U 2 +D 15 +L 10 +R 7 +L 18 +D 13 +R 2 +D 18 +U 8 +D 15 +U 14 +R 5 +L 9 +U 9 +D 18 +L 9 +U 6 +R 7 +L 10