diff options
Diffstat (limited to '2021')
-rw-r--r-- | 2021/day11.c | 8 |
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; + } } |