#include #include #include #include typedef struct { int id; int edges[8]; } Tile; int binary_string_to_decimal(char * str, int revers) { int result = 0; int str_length = 0; int i; while (str[str_length] != 0) str_length++; for (i=0; iid)) return 0; i=0; while (fgets(line, sizeof line, file) != NULL && i<10) { line_right[i] = line[9]; line_left[i] = line[0]; if (i == 0) strncpy(line_top, line, 10); if (i == 9) strncpy(line_bottom, line, 10); i++; } line_top[i] = line_right[i] = line_bottom[i] = line_left[i] = 0; tile->edges[0] = binary_string_to_decimal(line_top, 0); tile->edges[1] = binary_string_to_decimal(line_right, 0); tile->edges[2] = binary_string_to_decimal(line_bottom, 0); tile->edges[3] = binary_string_to_decimal(line_left, 0); tile->edges[4] = binary_string_to_decimal(line_top, 1); tile->edges[5] = binary_string_to_decimal(line_right, 1); tile->edges[6] = binary_string_to_decimal(line_bottom, 1); tile->edges[7] = binary_string_to_decimal(line_left, 1); return 1; } int parse_input(Tile * tiles, char * file_name) { FILE * file = fopen(file_name, "r"); int tiles_count = 0; if (file == NULL) { printf("Issue with file. Does it exist? 🤔"); exit(1); } while (parse_tile(&tiles[tiles_count], file)) tiles_count++; fclose(file); return tiles_count; } unsigned long long solve1(char file_name[6]) { unsigned long long result = 1; Tile tiles[256] = { 0 }; int tiles_count; int found_repeat_flag; int found_ids[4]; int found_ids_count = 0; int i,j,k,l; tiles_count = parse_input(tiles, file_name); // printf("Tiles count %d\n", tiles_count); // for (i=0; i