From c5a6ff0443fc9e5e890fe72cb13ea78d4fe2bbcb Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Wed, 2 Apr 2025 14:33:21 +0200 Subject: Added dreo coordinate solver --- test/122_coorddata_dreo/00_all.in | 0 test/122_coorddata_dreo/00_all.out | 1 + test/122_coorddata_dreo/coorddata_dreo.c | 58 ++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 test/122_coorddata_dreo/00_all.in create mode 100644 test/122_coorddata_dreo/00_all.out create mode 100644 test/122_coorddata_dreo/coorddata_dreo.c (limited to 'test/122_coorddata_dreo') diff --git a/test/122_coorddata_dreo/00_all.in b/test/122_coorddata_dreo/00_all.in new file mode 100644 index 0000000..e69de29 diff --git a/test/122_coorddata_dreo/00_all.out b/test/122_coorddata_dreo/00_all.out new file mode 100644 index 0000000..d6109db --- /dev/null +++ b/test/122_coorddata_dreo/00_all.out @@ -0,0 +1 @@ +All good diff --git a/test/122_coorddata_dreo/coorddata_dreo.c b/test/122_coorddata_dreo/coorddata_dreo.c new file mode 100644 index 0000000..0c75c5e --- /dev/null +++ b/test/122_coorddata_dreo/coorddata_dreo.c @@ -0,0 +1,58 @@ +#include "../test.h" + +#define POW_3_7 2187 +#define BOUND 45 * POW_3_7 +#define TGROUP UINT64_C(4278190335) + +cube_t transform(cube_t, uint8_t); +uint64_t coordinate_dreo_coord(cube_t, const void *); +cube_t coordinate_dreo_cube(uint64_t, const void *); +uint64_t coordinate_dreo_gendata(void *); + +void run(void) { + bool found; + uint64_t t; + char str[STRLENMAX]; + void *data; + size_t size; + cube_t cube; + uint64_t coord, coord2; + + size = coordinate_dreo_gendata(NULL); + data = malloc(size); + coordinate_dreo_gendata(data); + + for (coord = 0; coord < BOUND; coord++) { + cube = coordinate_dreo_cube(coord, data); + + if (!isconsistent(cube)) { + printf("Error: invcoord of %" PRId64 + " is not consistent\n", coord); + goto cleanup; + } + + for (t = 0, found = false; t < 48; t++) { + if (!((UINT64_C(1) << t) & TGROUP)) + continue; + + coord2 = coordinate_dreo_coord(transform(cube, t), data); + if (coord == coord2) { + found = true; + break; + } + } + + if (!found) { + printf("Error: invcoord of %" PRId64 " returns %" + PRId64 " with cube:\n", coord, coord2); + writecube("H48", cube, STRLENMAX, str); + printf("%s\n", str); + goto cleanup; + } + } + + printf("All good\n"); + +cleanup: + free(data); +} -- cgit v1.3