From ba40688c4a2fda8d18da492c7cfcbef9bfdb3c0a Mon Sep 17 00:00:00 2001 From: Orangerot Date: Sat, 17 Dec 2022 03:59:18 +0100 Subject: day09 --- 2022/day01/main | Bin 20760 -> 0 bytes 2022/day03/main | Bin 20800 -> 0 bytes 2022/day04/main | Bin 20672 -> 0 bytes 2022/day05/main | Bin 21080 -> 0 bytes 2022/day06/main | Bin 20704 -> 0 bytes 2022/day07/main | Bin 21104 -> 0 bytes 2022/day08/main | Bin 20864 -> 0 bytes 2022/day09/input1.txt | 8 + 2022/day09/input2.txt | 2000 +++++++++++++++++++++++++++++++++++++++++++++++++ 2022/day09/input3.txt | 8 + 2022/day09/main.c | 49 ++ 2022/day09/main2.c | 50 ++ 12 files changed, 2115 insertions(+) delete mode 100755 2022/day01/main delete mode 100755 2022/day03/main delete mode 100755 2022/day04/main delete mode 100755 2022/day05/main delete mode 100755 2022/day06/main delete mode 100755 2022/day07/main delete mode 100755 2022/day08/main create mode 100644 2022/day09/input1.txt create mode 100644 2022/day09/input2.txt create mode 100644 2022/day09/input3.txt create mode 100644 2022/day09/main.c create mode 100644 2022/day09/main2.c diff --git a/2022/day01/main b/2022/day01/main deleted file mode 100755 index 68fb10f..0000000 Binary files a/2022/day01/main and /dev/null differ diff --git a/2022/day03/main b/2022/day03/main deleted file mode 100755 index 6f77a3f..0000000 Binary files a/2022/day03/main and /dev/null differ diff --git a/2022/day04/main b/2022/day04/main deleted file mode 100755 index 498303f..0000000 Binary files a/2022/day04/main and /dev/null differ diff --git a/2022/day05/main b/2022/day05/main deleted file mode 100755 index 1d67170..0000000 Binary files a/2022/day05/main and /dev/null differ diff --git a/2022/day06/main b/2022/day06/main deleted file mode 100755 index 9963238..0000000 Binary files a/2022/day06/main and /dev/null differ diff --git a/2022/day07/main b/2022/day07/main deleted file mode 100755 index 2569466..0000000 Binary files a/2022/day07/main and /dev/null differ diff --git a/2022/day08/main b/2022/day08/main deleted file mode 100755 index e2d2028..0000000 Binary files a/2022/day08/main and /dev/null differ diff --git a/2022/day09/input1.txt b/2022/day09/input1.txt new file mode 100644 index 0000000..9874df2 --- /dev/null +++ b/2022/day09/input1.txt @@ -0,0 +1,8 @@ +R 4 +U 4 +L 3 +D 1 +R 4 +D 1 +L 5 +R 2 diff --git a/2022/day09/input2.txt b/2022/day09/input2.txt new file mode 100644 index 0000000..0739d8d --- /dev/null +++ b/2022/day09/input2.txt @@ -0,0 +1,2000 @@ +L 1 +D 2 +R 1 +L 1 +R 2 +L 1 +U 2 +L 2 +D 1 +L 2 +U 2 +R 2 +D 2 +L 1 +D 2 +U 2 +L 2 +R 2 +L 1 +U 2 +D 2 +U 2 +D 2 +L 1 +R 2 +L 2 +D 2 +R 1 +D 1 +R 2 +U 1 +R 2 +L 2 +R 1 +U 2 +R 1 +D 1 +U 1 +L 2 +R 1 +D 2 +U 1 +R 1 +U 2 +L 1 +R 2 +U 1 +R 2 +L 2 +R 1 +D 2 +R 1 +D 1 +U 2 +R 1 +D 1 +U 1 +D 2 +L 1 +U 1 +D 1 +R 2 +D 2 +R 1 +D 2 +L 2 +D 2 +U 1 +L 1 +D 1 +L 1 +R 2 +U 2 +L 2 +D 2 +L 2 +D 1 +U 2 +D 2 +L 2 +R 1 +D 1 +L 1 +U 1 +L 1 +U 2 +L 1 +U 1 +D 1 +R 1 +L 1 +R 2 +D 1 +L 2 +D 2 +R 1 +D 2 +R 1 +D 1 +R 2 +L 2 +U 1 +D 2 +L 2 +U 2 +D 2 +R 1 +D 1 +U 2 +R 2 +U 2 +D 3 +L 1 +U 2 +R 2 +D 1 +U 1 +L 1 +U 3 +L 3 +U 2 +L 3 +U 3 +L 3 +D 3 +R 1 +U 3 +R 3 +U 3 +D 2 +R 2 +U 2 +R 3 +L 3 +U 1 +R 1 +D 3 +L 1 +U 1 +R 3 +U 3 +D 1 +L 3 +R 1 +U 3 +D 2 +U 2 +D 2 +R 1 +U 2 +L 2 +U 3 +L 1 +U 3 +D 3 +U 3 +L 2 +R 3 +D 1 +L 1 +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3 +R 5 +D 2 +U 10 +L 17 +R 5 +U 15 +R 9 +D 5 +U 9 +L 12 +D 17 +R 14 +L 4 +R 14 +L 17 +D 9 +L 10 +D 17 +R 1 +U 2 +R 7 +U 13 +R 1 +U 17 +R 4 +L 3 +D 14 +U 11 +L 15 +R 6 +U 4 +D 8 +L 17 +D 3 +R 13 +U 10 +R 4 +U 5 +R 3 +U 16 +D 6 +L 5 +R 18 +L 11 +D 16 +U 7 +R 7 +U 1 +R 14 +U 14 +R 4 +D 3 +R 12 +D 13 +U 5 +D 8 +R 17 +L 9 +D 4 +L 13 +U 8 +R 13 +D 5 +U 17 +L 11 +U 13 +D 9 +L 8 +R 14 +L 15 +D 10 +R 11 +D 8 +L 10 +U 3 +L 3 +R 12 +L 9 +R 17 +U 10 +L 17 +U 13 +L 12 +U 1 +D 2 +R 1 +L 16 +R 11 +D 15 +L 8 +R 10 +L 12 +U 3 +L 17 +U 7 +R 6 +U 16 +R 1 +L 3 +R 5 +L 11 +R 4 +D 10 +L 1 +R 4 +U 12 +L 18 +R 8 +L 7 +R 16 +U 19 +R 10 +U 11 +D 12 +R 6 +U 17 +L 16 +D 19 +L 9 +U 1 +R 12 +U 12 +R 15 +D 4 +L 15 +R 4 +L 9 +R 15 +L 10 +R 7 +L 16 +U 16 +L 19 +U 5 +L 4 +U 12 +L 6 +U 5 +R 17 +U 11 +R 6 +U 15 +L 9 +D 4 +R 2 +L 7 +R 16 +L 13 +U 19 +R 4 +U 13 +L 18 +D 19 +U 15 +R 13 +L 11 +U 18 +D 2 +U 9 +D 18 +L 13 +D 13 +L 11 +U 3 +D 11 +U 16 +R 14 +D 6 +L 12 +D 9 +R 2 +D 14 +L 12 +R 15 +D 2 +R 11 +U 7 +D 9 +L 16 +R 12 +L 12 +D 14 +U 2 +D 12 +R 8 +U 9 +D 10 +U 12 +L 17 +U 19 +L 4 +U 15 +R 12 +L 11 +D 12 +L 8 +U 3 +R 7 +L 2 +D 4 +U 17 diff --git a/2022/day09/input3.txt b/2022/day09/input3.txt new file mode 100644 index 0000000..60bd43b --- /dev/null +++ b/2022/day09/input3.txt @@ -0,0 +1,8 @@ +R 5 +U 8 +L 8 +D 3 +R 17 +D 10 +L 25 +U 20 diff --git a/2022/day09/main.c b/2022/day09/main.c new file mode 100644 index 0000000..7f19df5 --- /dev/null +++ b/2022/day09/main.c @@ -0,0 +1,49 @@ +#include +#include + +typedef struct Cord_ Cord; + +typedef struct Cord_ { + int x,y; + Cord *next, *prev; +} Cord; + +Cord* updateTail(Cord *head, Cord *tail) +{ + int dy, dx, d; + dx = head->x - tail->x; + dy = head->y - tail->y; + d = dx * dx + dy * dy; + // distance <= 1 + if ( d <= 2) return tail; + tail->x += (dx + dx/abs(dx))/2; + tail->y += (dy + dy/abs(dy))/2; + + return tail; +} + +int main() +{ + char c; + int d; + Cord *h, *t; + t = &(Cord){0}; + h = &(Cord){0}; + while (scanf("%c %d\n", &c, &d) != EOF) + { + printf("%c %d\n", c, d); + for (int i = 0; i < d; i++) + { + h->x += (c == 'R') - (c == 'L'); + h->y += (c == 'U') - (c == 'D'); + printf("H %d %d \n", h->x, h->y); + t = updateTail(h, t); + printf("T %d %d \n", t->x, t->y); + } + } + +} + +// ./main < input2.txt | grep T | sort | uniq | wc -l + + diff --git a/2022/day09/main2.c b/2022/day09/main2.c new file mode 100644 index 0000000..da2382c --- /dev/null +++ b/2022/day09/main2.c @@ -0,0 +1,50 @@ +#include +#include + +typedef struct Cord_ Cord; + +typedef struct Cord_ { + int x,y; + Cord *next, *prev; +} Cord; + +Cord* updateTail(Cord *head, Cord *tail) +{ + int dy, dx, d; + dx = head->x - tail->x; + dy = head->y - tail->y; + d = dx * dx + dy * dy; + // distance <= 1 + if ( d <= 2) return tail; + tail->x += (dx + dx/abs(dx))/2; + tail->y += (dy + dy/abs(dy))/2; + + return tail; +} + +int main() +{ + char c; + int d; + Cord h[10] = {0}; + while (scanf("%c %d\n", &c, &d) != EOF) + { + printf("%c %d\n", c, d); + for (int i = 0; i < d; i++) + { + h[0].x += (c == 'R') - (c == 'L'); + h[0].y += (c == 'U') - (c == 'D'); + printf("H %d %d \n", h->x, h->y); + for (int i = 0; i < 9; i++) + { + updateTail(&h[i], &h[i+1]); + } + printf("T %d %d \n", h[9].x, h[9].y); + } + } + +} + +// ./main < input2.txt | grep T | sort | uniq | wc -l + + -- cgit v1.2.3