aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2020-12-11 13:37:12 +0100
committerMarvin Borner2020-12-11 13:37:12 +0100
commitde7fae88afbcab153a8dcc749d0ece099057b77a (patch)
tree6f6493dd76c97f57bf02566bcca475e8cde31387
parent15cc7bd34fa86d6a3f6dadfce0bf5db914670927 (diff)
Added first solution of day 11
-rw-r--r--2020/11/Makefile10
-rw-r--r--2020/11/input97
-rw-r--r--2020/11/solve.c94
3 files changed, 201 insertions, 0 deletions
diff --git a/2020/11/Makefile b/2020/11/Makefile
new file mode 100644
index 0000000..7f68e56
--- /dev/null
+++ b/2020/11/Makefile
@@ -0,0 +1,10 @@
+.PHONY: solve.c
+
+solve.o: solve.c
+ @gcc $+ -o $@ -lm
+
+clean:
+ @rm -f *.o
+
+run: solve.o
+ @./solve.o
diff --git a/2020/11/input b/2020/11/input
new file mode 100644
index 0000000..bbaf4ea
--- /dev/null
+++ b/2020/11/input
@@ -0,0 +1,97 @@
+LLLLLLLLL.L.LLL.L.LLLLL.LLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLL.LLLLL.LLLLLLLLLLLLLLLL
+LLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLL.LLLLL.LLLLLLLLLLLL.LLLLLL.LLLLL.LLLLLLL.LLLLLLLL
+LLLLLLLLL.LLLLL.LLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLL.LLLLLLL.LLLL.LLLLLL.LLLLL.LLLLLLLLLLLLLLLL
+LLLLLLLLLLLLL.LLLLLLLLL.LLLLLLLLLLLLLLLLL.LLLLLL.LLLLLL.LLLLLLLLLLLL.LLLLLL.LLLLL.LLLLLLL.LLLLLLLL
+LLLLLLLLLLLLLLL.LLLLLLL.LLL.LLLLLLLLLLLLLLLLLLLLL.LLLLL.LLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLL
+L..LL.L.L....L..L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.LLLLLLLL.LLLLLLLLLLL.LLLL.LLLLL.LLLLLLL.LLLL.LLLLLLLLLLLLLLLLLLLL.LLLLL.LL
+LLLLLLLLL.LLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLL.LLLLLLLLLLLLLLLL
+LLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLL.LLLLLL.LLLLL.LLLLLLLLLLLLLLLL
+LLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLL.LLLLLLL.LLLL..LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLL
+LLLLLLLLL.LLLLL.LLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLL.LLL.L.LLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLL.LLLLLLLL
diff --git a/2020/11/solve.c b/2020/11/solve.c
new file mode 100644
index 0000000..6fd8691
--- /dev/null
+++ b/2020/11/solve.c
@@ -0,0 +1,94 @@
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define SIZE 10000
+#define X_MAX 99
+#define Y_MAX 97
+
+// Quite magical, isn't it?
+#define ADJACENT(x, y, p) \
+ (x != 0 && y != 0 ? *(p - X_MAX - 1) == '#' : 0) + (y != 0 ? *(p - X_MAX) == '#' : 0) + \
+ (x != X_MAX && y != 0 ? *(p - X_MAX + 1) == '#' : 0) + \
+ (x != 0 ? *(p - 1) == '#' : 0) + (x != X_MAX ? *(p + 1) == '#' : 0) + \
+ (x != 0 && y != Y_MAX ? *(p + X_MAX - 1) == '#' : 0) + \
+ (y != Y_MAX ? *(p + X_MAX) == '#' : 0) + \
+ (x != X_MAX && y != Y_MAX ? *(p + X_MAX + 1) == '#' : 0);
+
+int count(char *buf1, char *buf2)
+{
+ int x = 0, y = 0;
+ for (char *p = buf1; *p; p++) {
+ if (*p == '.') {
+ x++;
+ buf2[p - buf1] = '.';
+ continue;
+ }
+
+ if (*p == '\n') {
+ x = 0;
+ y++;
+ buf2[p - buf1] = '\n';
+ continue;
+ }
+
+ int cnt = ADJACENT(x, y, p);
+
+ if (*p == 'L' && !cnt) {
+ buf2[p - buf1] = '#';
+ } else if (*p == '#' && cnt >= 4) {
+ buf2[p - buf1] = 'L';
+ } else {
+ buf2[p - buf1] = *p;
+ }
+
+ x++;
+ }
+
+ if (memcmp(buf1, buf2, SIZE)) {
+ return count(buf2, buf1); // Swap buffers
+ } else {
+ int cnt = 0;
+ for (char *p = buf1; *p; p++) {
+ if (*p == '#')
+ cnt++;
+ }
+ return cnt;
+ }
+}
+
+int part_one(char *data)
+{
+ int res = 0;
+
+ char buf1[SIZE] = { 0 };
+ memcpy(buf1, data, SIZE);
+ char buf2[SIZE] = { 0 };
+ memcpy(buf2, data, SIZE);
+
+ return count(buf1, buf2);
+}
+
+int part_two(char *data)
+{
+ int res = 0;
+
+ return res;
+}
+
+int main(int argc, char *argv[])
+{
+ FILE *fp = fopen("input", "r");
+ if (!fp)
+ exit(EXIT_FAILURE);
+ char buf[SIZE] = { 0 };
+ fread(buf, SIZE, 1, fp);
+
+ printf("%d\n", part_one(buf));
+ printf("%d\n", part_two(buf));
+
+ fclose(fp);
+ return 0;
+}