#include #include #define MAX_SIZE 6 int total_nr; int sym_stats1[36][6]; int sym_stats2[36][6]; int sym_stats3[36][36]; int horse_jump_stats[100]; int nr_squares_with_horse_jump_stats[37]; int horse_jump_mat_stats[37][37]; void print_solution(int (&matrix)[6][6]) { int n = MAX_SIZE; char min_sol[MAX_SIZE*MAX_SIZE+1]; bool first = true; for (int d = 0; d < 2; d++) for (int xd = 0; xd < 2; xd++) for (int yd = 0; yd < 2; yd++) { int map[MAX_SIZE]; for (int i = 0; i < n; i++) map[i] = -1; int nexti = 0; char sol[MAX_SIZE*MAX_SIZE+1]; char *s = sol; for (int x = 0; x < n; x++) for (int y = 0; y < n; y++) { int vx = xd == 0 ? x : n-1 - x; int vy = yd == 0 ? y : n-1 - y; int v = matrix[d == 0 ? vx : vy][d == 0 ? vy : vx]; if (map[v] == -1) map[v] = nexti++; *s++ = '0' + map[v]; } *s = '\0'; if (first || strcmp(sol, min_sol) < 0) strcpy(min_sol, sol); first = false; } //printf("p(\"%s\")\n", min_sol); printf("%s\n", min_sol); } void analyze(char* buffer, bool print_details) { total_nr++; int matrix[6][6]; { char *s = buffer; for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) matrix[i][j] = *s++ - '0'; } // Number of same colours per row and column /* int max_nr_same_colours = 0; for (int i = 0; i < 6; i++) { int cols[6]; for (int j = 0; j < 6; j++) cols[j] = 0; for (int j = 0; j < 6; j++) cols[matrix[i][j]]++; for (int j = 0; j < 6; j++) { if (cols[j] > max_nr_same_colours) max_nr_same_colours++; cols[j] = 0; } for (int j = 0; j < 6; j++) cols[matrix[j][i]]++; for (int j = 0; j < 6; j++) if (cols[j] > max_nr_same_colours) max_nr_same_colours++; } */ // Symmetries int max_nr_symmetric_per_colour = 0; int max_nr_symmetric_per_same_colour = 0; int max_sum_max_nr_symmetric_per_colour = 0; int sum_max_matchcolour = 0; int max_matchcolour[6][6]; for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) max_matchcolour[i][j] = 0; bool first = true; for (int d = 0; d < 2; d++) for (int xd = 0; xd < 2; xd++) for (int yd = 0; yd < 2; yd++) { int matchcolour[6][6]; for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) matchcolour[i][j] = 0; for (int x = 0; x < 6; x++) for (int y = 0; y < 6; y++) { int vx = xd == 0 ? x : 6-1 - x; int vy = yd == 0 ? y : 6-1 - y; matchcolour[matrix[x][y]][matrix[d == 0 ? vx : vy][d == 0 ? vy : vx]]++; } if (first) first = false; else { for (int i = 0; i < 6; i++) { if (matchcolour[i][i] > max_nr_symmetric_per_same_colour) max_nr_symmetric_per_same_colour = matchcolour[i][i]; for (int j = 0; j < 6; j++) { int v = matchcolour[i][j]; if (v > max_nr_symmetric_per_colour) max_nr_symmetric_per_colour = v; if (v > max_matchcolour[i][j]) max_matchcolour[i][j] = v; } } int sum_max = 0; for (int i = 0; i < 6; i++) { int max = 0; for (int j = 0; j < 6; j++) if (matchcolour[i][j] > max) max = matchcolour[i][j]; sum_max += max; } if (sum_max > max_sum_max_nr_symmetric_per_colour) max_sum_max_nr_symmetric_per_colour = sum_max; sum_max = 0; for (int i = 0; i < 6; i++) { int max = 0; for (int j = 0; j < 6; j++) if (matchcolour[j][i] > max) max = matchcolour[i][j]; sum_max += max; } if (sum_max > max_sum_max_nr_symmetric_per_colour) max_sum_max_nr_symmetric_per_colour = sum_max; } } for (int i = 0; i < 6; i++) sum_max_matchcolour += max_matchcolour[i][i]; //for (int i = 0; i < 6; i++) // for (int j = 0; j < 6; j++) // sum_max_matchcolour += max_matchcolour[i][j]; // Braces (three adjacent squares with the colours A B A) int nr_horz_braces = 0; int horz_braces[6]; int horz_brace_val = -1; int nr_vert_braces = 0; int vert_braces[6]; int vert_brace_val = -1; int brace_colours[6][6]; int brace_location[6][6]; int brace_location2[6][6]; for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) { brace_colours[i][j] = 0; brace_location[i][j] = 0; brace_location2[i][j] = 0; } for (int i = 0; i < 6; i++) horz_braces[i] = vert_braces[i] = 0; for (int i = 0; i < 6; i++) for (int j = 0; j+2 < 6; j++) { if (matrix[i][j] == matrix[i][j+2]) { nr_horz_braces++; horz_brace_val = matrix[i][j]; horz_braces[horz_brace_val]++; brace_colours[matrix[i][j]][matrix[i][j+1]]++; brace_location[i][j]++; brace_location[i][j+1]++; brace_location[i][j+2]++; if (i-1 >= 0) { brace_location2[i-1][j]++; brace_location2[i-1][j+1]++; brace_location2[i-1][j+2]++; } if (i+1 < 6) { brace_location2[i+1][j]++; brace_location2[i+1][j+1]++; brace_location2[i+1][j+2]++; } if (j-1 >= 0) brace_location2[i][j-1]++; if (j+3 < 6) brace_location2[i][j+3]++; } if (matrix[j][i] == matrix[j+2][i]) { nr_vert_braces++; vert_brace_val = matrix[j][i]; vert_braces[vert_brace_val]++; brace_colours[matrix[j][i]][matrix[j+1][i]]++; brace_location[j][i]++; brace_location[j+1][i]++; brace_location[j+2][i]++; if (i-1 >= 0) { brace_location2[j][i-1]++; brace_location2[j+1][i-1]++; brace_location2[j+2][i-1]++; } if (i+1 < 6) { brace_location2[j][i+1]++; brace_location2[j+1][i+1]++; brace_location2[j+2][i+1]++; } if (j-1 >= 0) brace_location2[j-1][i]++; if (j+3 < 6) brace_location2[j+3][i]++; } } int max_nr_same_brace_colours = 0; for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) if (brace_colours[i][j] > max_nr_same_brace_colours) max_nr_same_brace_colours = brace_colours[i][j]; int max_nr_same_brace_colours_per_rowcol = 0; for (int i = 0; i < 6; i++) { int nr_col = 0; int nr_row = 0; for (int j = 0; j < 6; j++) { nr_col += brace_colours[i][j]; nr_row += brace_colours[j][i]; } if (nr_col > max_nr_same_brace_colours_per_rowcol) max_nr_same_brace_colours_per_rowcol = nr_col; if (nr_row > max_nr_same_brace_colours_per_rowcol) max_nr_same_brace_colours_per_rowcol = nr_row; } int nr_braces_with_inverted_colours = 0; for (int j = 1; j < 6; j++) for (int i = 0; i < j; i++) if (brace_colours[i][j] > 0 && brace_colours[j][i] > 0) nr_braces_with_inverted_colours++; int nr_overlapping_braces = 0; int nr_neighbour_braces = 0; for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) { if (brace_location[i][j] > 1) nr_overlapping_braces += brace_location[i][j] - 1; if (brace_location[i][j] > 0 && brace_location2[i][j] > 0) nr_neighbour_braces++; } // Horse jumps // // X . . // . . X // int nr_horse_jumps = 0; int horse_jumps_per_colour[6]; for (int i = 0; i < 6; i++) horse_jumps_per_colour[i] = 0; int horse_jumps[6][6]; for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) horse_jumps[i][j] = 0; for (int i = 0; i+1 < 6; i++) for (int j = 0; j+2 < 6; j++) { if (matrix[i][j] == matrix[i+1][j+2]) { nr_horse_jumps++; horse_jumps[i][j]++; horse_jumps[i+1][j+2]++; horse_jumps_per_colour[matrix[i][j]]++; } if (matrix[i+1][j] == matrix[i][j+2]) { nr_horse_jumps++; horse_jumps[i+1][j]++; horse_jumps[i][j+2]++; horse_jumps_per_colour[matrix[i+1][j]]++; } if (matrix[j][i] == matrix[j+2][i+1]) { nr_horse_jumps++; horse_jumps[j][i]++; horse_jumps[j+2][i+1]++; horse_jumps_per_colour[matrix[j][i]]++; } if (matrix[j][i+1] == matrix[j+2][i]) { nr_horse_jumps++; horse_jumps[j][i+1]++; horse_jumps[j+2][i]++; horse_jumps_per_colour[matrix[j][i+1]]++; } } int max_horse_jumps = 0; for (int i = 0; i < 6; i++) if (horse_jumps_per_colour[i] > max_horse_jumps) max_horse_jumps = horse_jumps_per_colour[i]; int max_horse_jumps_per_square = 0; int nr_squares_with_horse_jump = 0; for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) { if (horse_jumps[i][j] > 0) nr_squares_with_horse_jump++; if (horse_jumps[i][j] > max_horse_jumps_per_square) max_horse_jumps_per_square = horse_jumps[i][j]; } if (nr_horse_jumps >= 100) fprintf(stderr, "HORSE JUMPS > 100\n"); else horse_jump_stats[nr_horse_jumps]++; nr_squares_with_horse_jump_stats[nr_squares_with_horse_jump]++; if (nr_horse_jumps < 37) horse_jump_mat_stats[nr_horse_jumps][nr_squares_with_horse_jump]++; // Horse jumps in a square // // . X Y . // Y . . X // X . . Y // . Y X . // int nr_square_horse_jumps = 0; int nr_wheel_8 = 0; int nr_wheel_7 = 0; int nr_wheel_6 = 0; int nr_wheel_5 = 0; for (int i = 0; i+3 < 6; i++) for (int j = 0; j+3 < 6; j++) { int v1 = matrix[i ][j+1]; int v2 = matrix[i+2][j ]; int v3 = matrix[i+3][j+2]; int v4 = matrix[i+1][j+3]; bool e12 = v1 == v2; bool e23 = v2 == v3; bool e34 = v3 == v4; bool e41 = v4 == v1; int wheel1 = 0; if (e12 && e23 && e34 && e41) { nr_square_horse_jumps++; wheel1 = 4; } else if (e12 && e23 || e23 && e34 || e34 && e41 || e41 && e12) wheel1 = 3; else if (e12 || e23 || e34 || e41 || v1 == v3 || v2 == v4) wheel1 = 2; v1 = matrix[i+1][j ]; v2 = matrix[i ][j+2]; v3 = matrix[i+2][j+3]; v4 = matrix[i+3][j+1]; e12 = v1 == v2; e23 = v2 == v3; e34 = v3 == v4; e41 = v4 == v1; int wheel2 = 0; if (e12 && e23 && e34 && e41) { nr_square_horse_jumps++; wheel2 = 4; } else if (e12 && e23 || e23 && e34 || e34 && e41 || e41 && e12) wheel2 = 3; else if (e12 || e23 || e34 || e41 || v1 == v3 || v2 == v4) wheel2 = 2; //if (wheel1 == 4 || wheel2 == 4) switch(wheel1 + wheel2) { case 8: nr_wheel_8++; break; case 7: nr_wheel_7++; break; case 6: nr_wheel_6++; break; case 5: nr_wheel_5++; break; } } // Triangles int nr_triangles = 0; for (int i = 0; i+2 < 6; i++) for (int j = 0; j+2 < 6; j++) { int val = matrix[i][j+1]; if ( matrix[i+2][j] == val && matrix[i+2][j+2] == val) nr_triangles++; val = matrix[i+2][j+1]; if ( matrix[i][j] == val && matrix[i][j+2] == val) nr_triangles++; val = matrix[i+1][j]; if ( matrix[i][j+2] == val && matrix[i+2][j+2] == val) nr_triangles++; val = matrix[i+1][j+2]; if ( matrix[i][j] == val && matrix[i+2][j] == val) nr_triangles++; } int nr_same_colour_trans = 0; int max_same_colour_trans = 0; int nr_same_dir_colour_trans = 0; int max_same_dir_colour_trans = 0; for (int i = 0; i+1 < 6; i++) { int colourmat[6][6]; for (int j = 0; j < 6; j++) for (int k = 0; k < 6; k++) colourmat[j][k] = 0; for (int j = 0; j < 6; j++) colourmat[matrix[i][j]][matrix[i+1][j]]++; int same_colour_trans = 0; int same_dir_colour_trans = 0; for (int j = 0; j < 6; j++) for (int k = 0; k < 6; k++) { int v = colourmat[j][k]; if (v > 1) same_dir_colour_trans += v; if (j < k) { v += colourmat[k][j]; if (v > 1) same_colour_trans += v; } } nr_same_colour_trans += same_colour_trans; if (same_colour_trans > max_same_colour_trans) max_same_colour_trans = same_colour_trans; nr_same_dir_colour_trans += same_dir_colour_trans; if (same_dir_colour_trans > max_same_dir_colour_trans) max_same_dir_colour_trans = same_dir_colour_trans; for (int j = 0; j < 6; j++) for (int k = 0; k < 6; k++) colourmat[j][k] = 0; for (int j = 0; j < 6; j++) colourmat[matrix[j][i]][matrix[j][i+1]]++; same_colour_trans = 0; for (int j = 0; j < 6; j++) for (int k = 0; k < 6; k++) { int v = colourmat[j][k]; if (v > 1) same_dir_colour_trans += v; if (j < k) { v += colourmat[k][j]; if (v > 1) same_colour_trans += v; } } nr_same_colour_trans += same_colour_trans; if (same_colour_trans > max_same_colour_trans) max_same_colour_trans = same_colour_trans; nr_same_dir_colour_trans += same_dir_colour_trans; if (same_dir_colour_trans > max_same_dir_colour_trans) max_same_dir_colour_trans = same_dir_colour_trans; } int max_equal_sequence = 0; for (int i2 = 1; i2 < 6; i2++) for (int i1 = 0; i1 < i2; i1++) for (int j1 = 0; j1+2 < 6; j1++) for (int j2 = 0; j2+2 < 6; j2++) { int s = 0; for (; j1+s < 6 && j2+s < 6 && matrix[i1][j1+s] == matrix[i2][j2+s]; s++) ; if (s > max_equal_sequence) max_equal_sequence = s; s = 0; for (; j1+s < 6 && j2+s < 6 && matrix[j1+s][i1] == matrix[j2+s][i2]; s++) ; if (s > max_equal_sequence) max_equal_sequence = s; } int nr_edges_o[6][6]; int max_nr_edges_o[6][6]; for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) { nr_edges_o[i][j] = 0; max_nr_edges_o[i][j] = 0; } for (int i = 0; i+1 < 6; i++) for (int j = 0; j < 6; j++) nr_edges_o[matrix[i][j]][matrix[i+1][j]]++; for (int j = 1; j < 6; j++) for (int i = 0; i < j; i++) { int v = nr_edges_o[i][j]; if (v > max_nr_edges_o[i][j]) max_nr_edges_o[i][j] = v; v = nr_edges_o[j][i]; if (v > max_nr_edges_o[i][j]) max_nr_edges_o[i][j] = v; } for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) nr_edges_o[i][j] = 0; for (int i = 0; i+1 < 6; i++) for (int j = 0; j < 6; j++) nr_edges_o[matrix[j][i]][matrix[j][i+1]]++; for (int j = 1; j < 6; j++) for (int i = 0; i < j; i++) { int v = nr_edges_o[i][j]; if (v > max_nr_edges_o[i][j]) max_nr_edges_o[i][j] = v; v = nr_edges_o[j][i]; if (v > max_nr_edges_o[i][j]) max_nr_edges_o[i][j] = v; } int nr_same_direction_2 = 0; int nr_same_direction_3 = 0; int nr_same_direction_4 = 0; for (int j = 1; j < 6; j++) for (int i = 0; i < j; i++) { int v = max_nr_edges_o[i][j]; if (v == 4) nr_same_direction_4++; else if (v == 3) nr_same_direction_3++; else if (v == 2) nr_same_direction_2++; } int nr_edges[6][6][4]; for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) for (int d = 0; d < 4; d++) nr_edges[i][j][d] = 0; for (int i = 0; i+1 < 6; i++) for (int j = 0; j < 6; j++) { int c1, c2; c1 = matrix[i][j]; c2 = matrix[i+1][j]; if (c1 < c2) nr_edges[c1][c2][0]++; else nr_edges[c2][c1][2]++; c1 = matrix[j][i]; c2 = matrix[j][i+1]; if (c1 < c2) nr_edges[c1][c2][1]++; else nr_edges[c2][c1][3]++; } int nr_edges_one_orientation = 0; for (int j = 1; j < 6; j++) for (int i = 0; i < j; i++) { int v = 0; for (int d = 0; d < 4; d++) if (nr_edges[i][j][d] > v) v = nr_edges[i][j][d]; if (v != max_nr_edges_o[i][j]) printf("nr_edges %d %d %d <> %d\n", i, j, v, max_nr_edges_o[i][j]); if (nr_edges[i][j][0] == 0 && nr_edges[i][j][2] == 0 || nr_edges[i][j][1] == 0 && nr_edges[i][j][3] == 0) nr_edges_one_orientation++; } bool no_braces = nr_horz_braces + nr_vert_braces == 0; bool at_most_one_brace = nr_horz_braces + nr_vert_braces <= 1; bool at_most_one_brace_in_both_direction = nr_horz_braces <= 1 && nr_vert_braces <= 1; bool at_most_one_brace_in_both_direction_not_same_colour = at_most_one_brace_in_both_direction && (nr_horz_braces == 0 || nr_vert_braces == 0 || horz_brace_val != vert_brace_val); if (print_details) { print_solution(matrix); printf("max_nr_symmetric_per_colour: %d\n", max_nr_symmetric_per_colour); printf("max_nr_symmetric_per_same_colour: %d\n", max_nr_symmetric_per_same_colour); printf("max_sum_max_nr_symmetric_per_colour: %d\n", max_sum_max_nr_symmetric_per_colour); printf("sum_max_matchcolour: %d\n", sum_max_matchcolour); printf("nr_horz_braces: %d\n", nr_horz_braces); printf("horz_brace_val: %d\n", horz_brace_val); printf("nr_vert_braces: %d\n", nr_vert_braces); printf("vert_brace_val: %d\n", vert_brace_val); printf("max_nr_same_brace_colours: %d\n", max_nr_same_brace_colours); printf("max_nr_same_brace_colours_per_rowcol: %d\n", max_nr_same_brace_colours_per_rowcol); printf("nr_braces_with_inverted_colours: %d\n", nr_braces_with_inverted_colours); printf("nr_overlapping_braces: %d\n", nr_overlapping_braces); printf("nr_neighbour_braces: %d\n", nr_neighbour_braces); printf("nr_horse_jumps: %d\n", nr_horse_jumps); printf("max_horse_jumps: %d\n", max_horse_jumps); printf("max_horse_jumps_per_square: %d\n", max_horse_jumps_per_square); printf("nr_squares_with_horse_jump: %d\n", nr_squares_with_horse_jump); printf("nr_square_horse_jumps: %d\n", nr_square_horse_jumps); printf("nr_wheel_8: %d\n", nr_wheel_8); printf("nr_wheel_7: %d\n", nr_wheel_7); printf("nr_wheel_6: %d\n", nr_wheel_6); printf("nr_wheel_5: %d\n", nr_wheel_5); printf("nr_triangles: %d\n", nr_triangles); printf("nr_same_colour_trans: %d\n", nr_same_colour_trans); printf("max_same_colour_trans: %d\n", max_same_colour_trans); printf("nr_same_dir_colour_trans: %d\n", nr_same_dir_colour_trans); printf("max_same_dir_colour_trans: %d\n", max_same_dir_colour_trans); printf("max_equal_sequence: %d\n", max_equal_sequence); printf("nr_same_direction_2: %d\n", nr_same_direction_2); printf("nr_same_direction_3: %d\n", nr_same_direction_3); printf("nr_same_direction_4: %d\n", nr_same_direction_4); printf("nr_edges_one_orientation: %d\n", nr_edges_one_orientation); printf("no_braces: %s\n", no_braces ? "true" : "false"); printf("at_most_one_brace: %s\n", at_most_one_brace ? "true" : "false"); printf("at_most_one_brace_in_both_direction: %s\n", at_most_one_brace_in_both_direction ? "true" : "false"); printf("at_most_one_brace_in_both_direction_not_same_colour: %s\n", at_most_one_brace_in_both_direction_not_same_colour ? "true" : "false"); } /* Original 50 if ( true //&& no_braces //&& at_most_one_brace && at_most_one_brace_in_both_direction_not_same_colour //&& nr_overlapping_braces == 0 //&& max_horse_jumps <= 5 //&& nr_square_horse_jumps <= 0 //&& nr_square_horse_jumps <= 1 //&& nr_triangles == 0 //&& nr_triangles <= 1 && max_same_colour_trans <= 2 && max_equal_sequence <= 3 && nr_same_direction_4 == 0 ) //*/ /* && nr_overlapping_braces == 0 => 44 // && nr_wheel_8 == 0 => 29 // && nr_wheel_7 == 0 => 25 // (&& nr_wheel_6 == 0 => 0) // && max_same_dir_colour_trans == 0 => 4 if ( true //&& no_braces //&& at_most_one_brace && at_most_one_brace_in_both_direction_not_same_colour && nr_overlapping_braces == 0 //&& max_horse_jumps <= 5 //&& nr_square_horse_jumps <= 0 //&& nr_square_horse_jumps <= 1 && nr_wheel_8 == 0 && nr_wheel_7 == 0 //&& nr_wheel_6 == 0 //&& nr_triangles == 0 //&& nr_triangles <= 1 && max_same_colour_trans <= 2 && max_same_dir_colour_trans == 0 && max_equal_sequence <= 3 && nr_same_direction_4 == 0 ) //*/ //* -- at_most_one_brace_in_both_direction_not_same_colour // && nr_overlapping_braces == 0 => 44 // && nr_neighbour_braces == 0 => 1 if ( true //&& no_braces //&& at_most_one_brace //&& at_most_one_brace_in_both_direction_not_same_colour && nr_overlapping_braces == 0 && nr_neighbour_braces == 0 && nr_wheel_8 == 0 && nr_wheel_7 == 0 //&& nr_wheel_6 == 0 //&& no_braces //&& nr_neighbour_braces == 0 //&& max_horse_jumps <= 5 //&& nr_square_horse_jumps <= 0 //&& nr_square_horse_jumps <= 1 //&& nr_triangles == 0 && nr_triangles <= 1 && max_same_colour_trans <= 2 && max_same_dir_colour_trans == 0 && max_equal_sequence <= 3 && nr_same_direction_4 == 0 ) //*/ /* if ( true //&& max_nr_symmetric_per_colour <= 3 && max_sum_max_nr_symmetric_per_colour < 36 && nr_horz_braces + nr_vert_braces == 6 && //&& max_same_colour_trans == 2 //&& nr_same_direction_3 == 0 //&& nr_same_direction_4 == 0 //&& nr_square_horse_jumps <= 0 //&& nr_triangles <= 2 ) //*/ /* if ( true && max_nr_same_brace_colours_per_rowcol == 1 && nr_triangles <= 1 && sum_max_matchcolour <= 13 && max_sum_max_nr_symmetric_per_colour <= 16 ) //*/ { printf("p(\"%s\",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\n", buffer, no_braces ? 0 : at_most_one_brace ? 1 : 2, nr_triangles, nr_horse_jumps, max_horse_jumps, nr_square_horse_jumps, nr_same_colour_trans, max_same_colour_trans, max_equal_sequence, nr_same_direction_2, nr_same_direction_3, nr_same_direction_4, nr_horz_braces + nr_vert_braces, max_nr_symmetric_per_colour, max_sum_max_nr_symmetric_per_colour); } sym_stats1[max_sum_max_nr_symmetric_per_colour-1][max_nr_symmetric_per_colour-1]++; sym_stats2[max_sum_max_nr_symmetric_per_colour-1][max_nr_symmetric_per_same_colour-1]++; sym_stats3[max_sum_max_nr_symmetric_per_colour-1][sum_max_matchcolour-1]++; } void analyzeFile(const char* name) { FILE* f = fopen(name, "rt"); char buffer[40]; while (fgets(buffer, 39, f)) { buffer[36] = '\0'; analyze(buffer, false); } fclose(f); } int main(int argc, char* argv[]) { total_nr = 0; for (int i = 0; i < 36; i++) { for (int j = 0; j < 6; j++) { sym_stats1[i][j] = 0; sym_stats2[i][j] = 0; } for (int j = 0; j < 36; j++) sym_stats3[i][j] = 0; } for (int i = 0; i < 100; i++) horse_jump_stats[i] = 0; for (int i = 0; i < 37; i++) { nr_squares_with_horse_jump_stats[i] = 0; for (int j = 0; j < 37; j++) horse_jump_mat_stats[i][j] = 0; } analyzeFile("FSwN.txt"); //("010213243504502135415420230314154253"); FILE* f = fopen("FSwN_stat.txt", "wt"); fprintf(f, " "); for (int j = 0; j < 6; j++) fprintf(f, "%5d:", j+1); fprintf(f, "\n"); for (int i = 0; i < 36; i++) { fprintf(f, "%2d:", i+1); int sum = 0; for (int j = 0; j < 6; j++) { sum += sym_stats1[i][j]; fprintf(f,"%6d", sym_stats1[i][j]); } fprintf(f, " %7d\n", sum); } fprintf(f,"\n"); fprintf(f, " "); for (int j = 0; j < 6; j++) fprintf(f, "%5d:", j+1); fprintf(f, "\n"); for (int i = 0; i < 36; i++) { fprintf(f, "%2d:", i+1); int sum = 0; for (int j = 0; j < 6; j++) { sum += sym_stats2[i][j]; fprintf(f,"%6d", sym_stats2[i][j]); } fprintf(f, " %7d\n", sum); } fprintf(f,"\n"); fprintf(f, " "); for (int j = 0; j < 36; j++) fprintf(f, "%5d:", j+1); fprintf(f, "\n"); for (int i = 0; i < 36; i++) { fprintf(f, "%2d:", i+1); for (int j = 0; j < 36; j++) fprintf(f,"%6d", sym_stats3[i][j]); fprintf(f, "\n"); } fprintf(f,"\nnr_horse_jumps:\n"); int sum = 0; for (int i = 99; i >= 0; i--) if (horse_jump_stats[i] > 0) { sum += horse_jump_stats[i]; fprintf(f, "%3d: %6d (%lf%%)\n", i, horse_jump_stats[i], (double)sum * 100.00 / (double)total_nr); } fprintf(f,"\nnr_squares_with_horse_jump:\n"); sum = 0; for (int i = 36; i >= 0; i--) if (nr_squares_with_horse_jump_stats[i] > 0) { sum += nr_squares_with_horse_jump_stats[i]; fprintf(f, "%3d: %6d (%lf%%)\n", i, nr_squares_with_horse_jump_stats[i], (double)sum * 100.00 / (double)total_nr); } fprintf(f, " "); for (int j = 0; j < 37; j++) fprintf(f, "%5d:", j+1); fprintf(f, "\n"); for (int i = 0; i < 37; i++) { fprintf(f, "%2d:", i+1); for (int j = 0; j < 37; j++) fprintf(f,"%6d", horse_jump_mat_stats[i][j]); fprintf(f, "\n"); } fclose(f); analyze("012314345402201235153041324152505304", true); }