coorddata_dreo.c (1385B)
1 #include "../test.h" 2 3 #define POW_3_7 2187 4 #define BOUND 45 * POW_3_7 5 #define TGROUP UINT64_C(4278190335) 6 7 cube_t transform(cube_t, uint8_t); 8 uint64_t coordinate_dreo_coord(cube_t, const unsigned char *); 9 cube_t coordinate_dreo_cube(uint64_t, const unsigned char *); 10 uint64_t coordinate_dreo_gendata(unsigned char *); 11 12 void run(void) { 13 bool found; 14 uint64_t t; 15 char str[STRLENMAX]; 16 unsigned char *data; 17 size_t size; 18 cube_t cube; 19 oriented_cube_t oc; 20 uint64_t coord, coord2; 21 22 size = coordinate_dreo_gendata(NULL); 23 data = malloc(size); 24 coordinate_dreo_gendata(data); 25 26 for (coord = 0; coord < BOUND; coord++) { 27 cube = coordinate_dreo_cube(coord, data); 28 29 oc = (oriented_cube_t) { .cube = cube, .orientation = 0 }; 30 if (!isconsistent(oc)) { 31 printf("Error: invcoord of %" PRId64 32 " is not consistent\n", coord); 33 goto cleanup; 34 } 35 36 for (t = 0, found = false; t < 48; t++) { 37 if (!((UINT64_C(1) << t) & TGROUP)) 38 continue; 39 40 coord2 = coordinate_dreo_coord(transform(cube, t), data); 41 if (coord == coord2) { 42 found = true; 43 break; 44 } 45 } 46 47 if (!found) { 48 oc = (oriented_cube_t){.cube = cube, .orientation = 0}; 49 printf("Error: invcoord of %" PRId64 " returns %" 50 PRId64 " with cube:\n", coord, coord2); 51 writecube(oc, STRLENMAX, str); 52 printf("%s\n", str); 53 goto cleanup; 54 } 55 } 56 57 printf("All good\n"); 58 59 cleanup: 60 free(data); 61 }