summaryrefslogtreecommitdiff
path: root/Advent-of-Code-2022/aoc-9
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2022-12-09 23:29:28 +0200
committerkartofen <mladenovnasko0@gmail.com>2022-12-09 23:29:28 +0200
commitb284257038b6d4777de7c6ef5499e8b7c64b53b5 (patch)
tree256b0f105f0775e206aed8536bbd5a28eea16cfb /Advent-of-Code-2022/aoc-9
parentc5a8824311e7c814f58593f43b0528505756f46a (diff)
day 8 and day 9
Diffstat (limited to 'Advent-of-Code-2022/aoc-9')
-rwxr-xr-xAdvent-of-Code-2022/aoc-9/build.sh5
-rw-r--r--Advent-of-Code-2022/aoc-9/input.txt2000
-rw-r--r--Advent-of-Code-2022/aoc-9/main.c113
-rw-r--r--Advent-of-Code-2022/aoc-9/sample.txt8
4 files changed, 2126 insertions, 0 deletions
diff --git a/Advent-of-Code-2022/aoc-9/build.sh b/Advent-of-Code-2022/aoc-9/build.sh
new file mode 100755
index 0000000..30f495e
--- /dev/null
+++ b/Advent-of-Code-2022/aoc-9/build.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -xe
+
+gcc -o main main.c -Wall -Wextra -pedantic
diff --git a/Advent-of-Code-2022/aoc-9/input.txt b/Advent-of-Code-2022/aoc-9/input.txt
new file mode 100644
index 0000000..b9aa23e
--- /dev/null
+++ b/Advent-of-Code-2022/aoc-9/input.txt
@@ -0,0 +1,2000 @@
+R 1
+U 2
+R 1
+L 2
+D 2
+U 1
+R 2
+U 1
+L 2
+U 1
+D 2
+R 1
+D 1
+L 1
+U 2
+D 2
+L 2
+D 1
+U 2
+D 2
+L 1
+U 1
+L 2
+D 2
+U 2
+L 1
+U 2
+L 1
+R 2
+U 1
+L 1
+R 2
+D 1
+U 2
+R 1
+U 1
+R 2
+U 1
+R 2
+U 1
+D 1
+U 1
+D 1
+L 2
+D 2
+R 1
+U 1
+R 1
+U 1
+L 1
+U 1
+D 2
+R 2
+D 2
+L 2
+U 2
+R 1
+D 1
+U 1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 7
+U 13
+D 15
+U 15
+L 6
+D 7
+R 15
+L 10
+U 6
+R 7
+L 13
+U 3
+D 9
+L 3
+D 10
+R 14
+D 15
+L 6
+D 4
+U 11
+L 11
+D 6
+U 8
+D 15
+R 5
+L 9
+D 15
+U 15
+R 9
+D 11
+U 7
+L 9
+U 8
+D 2
+L 4
+D 11
+U 12
+R 11
+U 5
+L 12
+U 5
+R 14
+L 10
+R 6
+D 3
+L 13
+U 6
+R 10
+D 10
+U 9
+D 3
+R 7
+L 13
+R 15
+U 6
+L 13
+U 11
+D 9
+L 7
+R 8
+U 6
+R 12
+U 2
+L 8
+U 10
+D 11
+U 14
+R 3
+L 15
+U 9
+L 2
+U 2
+D 11
+L 11
+R 3
+D 14
+U 3
+L 1
+U 2
+D 12
+L 5
+R 5
+D 10
+L 16
+R 4
+U 3
+L 6
+R 9
+L 7
+R 2
+U 15
+R 6
+L 12
+D 16
+L 16
+D 15
+U 12
+L 6
+D 9
+U 8
+L 10
+D 11
+U 4
+D 12
+U 7
+D 14
+U 1
+D 10
+R 10
+D 14
+L 5
+D 6
+R 8
+L 16
+U 7
+L 12
+R 13
+L 11
+D 12
+R 5
+D 11
+L 5
+R 4
+D 15
+L 13
+D 10
+R 2
+L 16
+D 14
+R 15
+D 11
+U 2
+D 12
+L 11
+D 1
+R 5
+D 6
+U 13
+L 10
+R 1
+U 10
+D 12
+L 10
+D 10
+R 11
+L 10
+D 11
+L 3
+R 11
+D 12
+L 6
+U 2
+L 10
+D 9
+L 11
+U 12
+D 14
+L 6
+U 16
+D 2
+L 2
+D 14
+U 7
+R 12
+D 14
+L 4
+U 3
+R 16
+D 2
+L 5
+R 10
+L 1
+R 11
+L 14
+D 3
+L 17
+D 4
+U 1
+R 8
+D 8
+L 5
+U 1
+L 13
+D 15
+U 17
+L 1
+D 14
+U 4
+R 1
+U 2
+D 14
+R 10
+U 14
+D 17
+R 10
+U 13
+D 12
+U 8
+L 11
+U 17
+R 12
+U 6
+D 8
+R 10
+U 16
+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+D 15
+U 2
+D 7
+L 15
+U 1
+L 16
+R 8
+L 13
+R 3
+D 8
+R 1
+D 8
+L 10
+U 16
+R 16
+L 2
+U 3
+D 9
+U 12
+D 1
+L 10
+D 15
+U 7
+R 3
+D 15
+U 4
+L 6
+R 14
+U 13
+R 16
+U 2
+R 9
+U 15
+D 8
+L 8
+R 17
+D 3
+L 17
+D 13
+U 8
+D 11
+R 13
+L 3
+D 2
+U 14
+R 1
+U 10
+R 11
+D 16
+L 10
+R 17
+U 7
+L 13
+R 3
+L 18
+R 5
+U 7
+L 12
+D 4
+U 5
+L 17
+R 18
+L 4
+R 19
+L 12
+U 17
+R 2
+L 11
+R 9
+D 16
+R 19
+L 18
+U 11
+D 4
+R 13
+L 18
+U 13
+R 19
+D 3
+R 10
+L 3
+R 5
+D 2
+R 2
+L 18
+D 15
+R 19
+L 5
+D 4
+U 5
+R 12
+D 15
+L 13
+R 16
+U 16
+L 6
+U 12
+L 8
diff --git a/Advent-of-Code-2022/aoc-9/main.c b/Advent-of-Code-2022/aoc-9/main.c
new file mode 100644
index 0000000..00945eb
--- /dev/null
+++ b/Advent-of-Code-2022/aoc-9/main.c
@@ -0,0 +1,113 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if 0
+ #define KNOTS 2
+#else
+ #define KNOTS 10
+#endif
+
+#if 0
+ #define FILENAME "sample.txt"
+#else
+ #define FILENAME "input.txt"
+#endif
+
+#define SIDE 1000
+#define OFFSET (SIDE/2)
+
+typedef enum {
+ NONE = 0,
+ NORTH = 1,
+ SOUTH = -1,
+ EAST = 1,
+ WEST = -1
+} direction;
+
+int board[SIDE][SIDE] = {0};
+int rope[KNOTS][2] = {0};
+direction rope_dir[KNOTS][2] = {0};
+
+void move(int k)
+{
+ rope[k][0] += rope_dir[k][0];
+ rope[k][1] += rope_dir[k][1];
+}
+
+void parse_dir(char d)
+{
+ rope_dir[0][0] = NONE;
+ rope_dir[0][1] = NONE;
+
+ switch(d) {
+ case 'U':
+ rope_dir[0][1] = NORTH;
+ return;
+ case 'D':
+ rope_dir[0][1] = SOUTH;
+ return;
+ case 'R':
+ rope_dir[0][0] = EAST;
+ return;
+ case 'L':
+ rope_dir[0][0] = WEST;
+ return;
+ }
+}
+
+void parse()
+{
+ FILE *fp = fopen(FILENAME, "r");
+ if(!fp) {
+ fprintf(stderr, "ERROR: Could not open file: %s\n", FILENAME);
+ exit(1);
+ }
+
+ char line[256];
+ while(fgets(line, sizeof(line), fp))
+ {
+ parse_dir(strtok(line, " ")[0]);
+ int n = atoi(strtok(NULL, " "));
+
+ for(int i = 0; i < n; i++)
+ {
+ move(0);
+ for(int j = 1; j < KNOTS; j++)
+ {
+ int hor = rope[j-1][0] - rope[j][0];
+ if(hor > 0) rope_dir[j][0] = EAST;
+ else if(hor < 0) rope_dir[j][0] = WEST;
+ else rope_dir[j][0] = NONE;
+
+ int vert = rope[j-1][1] - rope[j][1];
+ if(vert > 0) rope_dir[j][1] = NORTH;
+ else if(vert < 0) rope_dir[j][1] = SOUTH;
+ else rope_dir[j][1] = NONE;
+
+ if(abs(vert) > 1 || abs(hor) > 1)
+ move(j);
+ }
+
+ board[rope[KNOTS-1][0] + OFFSET][rope[KNOTS-1][1] + OFFSET]++;
+ }
+ }
+
+ fclose(fp);
+}
+
+int sum()
+{
+ int sum = 0;
+ for(int i = 0; i < SIDE; i++)
+ for(int j = 0; j < SIDE; j++)
+ if(board[j][i] > 0) sum++;
+ return sum;
+}
+
+int main(void)
+{
+ parse();
+ printf("%d\n", sum());
+ return 0;
+}
diff --git a/Advent-of-Code-2022/aoc-9/sample.txt b/Advent-of-Code-2022/aoc-9/sample.txt
new file mode 100644
index 0000000..60bd43b
--- /dev/null
+++ b/Advent-of-Code-2022/aoc-9/sample.txt
@@ -0,0 +1,8 @@
+R 5
+U 8
+L 8
+D 3
+R 17
+D 10
+L 25
+U 20