summary refs log tree commit diff homepage
diff options
context:
space:
mode:
-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;
+	}
 }
in/hilex/c.l?id=2901b90df2243e7844106cff525967b1d3305a8b&follow=1'>Clean up C lexerJune McEnroe 2020-12-29Clean up hilex code somewhatJune McEnroe 2020-12-29Match lex/yacc %% %{ %} lines as MacroJune McEnroe 2020-12-29Match top-level C definitions as IdentifierTagJune McEnroe 2020-12-29Match C type declarations as IdentifierTagJune McEnroe 2020-12-29Match function-like macro definitions as IdentifierTagJune McEnroe 2020-12-29Reconfigure C macro start conditionsJune McEnroe 2020-12-29Document HTML class namesJune McEnroe 2020-12-29Rename Tag class to IdentifierTagJune McEnroe 2020-12-29Change HTML class from hi to hilexJune McEnroe 2020-12-29Add hilex HTML outputJune McEnroe