#include #define MAX_POINTS 8192 typedef struct { int x; int y; int z; int w; } Point; int points_get_neighbors_count(Point * points, int * points_count, Point * target) { int i,x,y,z,w, result = 0; for (x=-1; x<2; x++) for (y=-1; y<2; y++) for (z=-1; z<2; z++) for (w=-1; w<2; w++) for (i=0; i < *points_count; i++) if (points[i].x == target->x + x && points[i].y == target->y + y && points[i].z == target->z + z && points[i].w == target->w + w) result++; return result - 1; } void points_copy(Point * source, int * source_count, Point * target, int * target_count) { for (int i=0; i < *source_count; i ++) target[i] = source[i]; *target_count = *source_count; } int solve1(char file_name[6], int cycles) { FILE * file = fopen(file_name, "r"); if (file == NULL) return -1; char line[16]; int i,j,k, active_neighbors; int x=0, y=0, z=0, w=0; Point points1[MAX_POINTS], points2[MAX_POINTS], neighbor; int points1_count = 0, points2_count = 0; while (fgets(line, sizeof line, file) != NULL) { for (x=0; line[x] != '\n'; x++) if (line[x] == '#') { points1[points1_count].x = x; points1[points1_count].y = y; points1[points1_count].z = z; points1[points1_count].w = w; points1_count++; } y++; } fclose(file); /* printf("cycle: 0\n"); */ /* for (l=0; l < points1_count; l++) */ /* printf("%d,%d,%d\n", points1[l].x, points1[l].y, points1[l].z); */ for (i=0; i