summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-12-11 14:09:14 -0500
committerJune McEnroe <june@causal.agency>2021-12-11 14:09:14 -0500
commit699f91ad183872e659b3f3967e605fae1d6be666 (patch)
tree28f8fe1f2fcdc7828e9bf65e13069d188ff75ea0
parentSolve day 11 part 1 (diff)
downloadaoc-699f91ad183872e659b3f3967e605fae1d6be666.tar.gz
aoc-699f91ad183872e659b3f3967e605fae1d6be666.zip
Solve day 11 part 2
-rw-r--r--2021/day11.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/2021/day11.c b/2021/day11.c
index d153bf1..666eea7 100644
--- a/2021/day11.c
+++ b/2021/day11.c
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 struct Grid {
 	int e[10][10];
 };
@@ -43,4 +44,11 @@ int main(void) {
 		flashes += step(&grid, grid);
 	}
 	printf("%d\n", flashes);
+	struct Grid zero = {0};
+	for (int i = 100;; ++i) {
+		step(&grid, grid);
+		if (memcmp(&grid, &zero, sizeof(grid))) continue;
+		printf("%d\n", i+1);
+		break;
+	}
 }