Reformatting.

This commit is contained in:
2022-09-06 18:45:31 +10:00
parent 7063f4b763
commit 5471bcf102
5 changed files with 960 additions and 955 deletions

View File

@@ -25,58 +25,60 @@
bool buf[NUM];
int main() {
uint32_t seed = 1;
bool clash;
size_t max = 0;
do {
if ((seed - 1) % 1000000 == 0)
printf("Checked up to: %u\r", seed - 1);
uint32_t seed = 1;
bool clash;
size_t max = 0;
do {
if ((seed - 1) % 1000000 == 0)
printf("Checked up to: %u\r", seed - 1);
// reset for test
memset(buf, 0, sizeof(bool) * NUM);
clash = false;
// reset for test
memset(buf, 0, sizeof(bool) * NUM);
clash = false;
// check for collisions
for (size_t i = 0; i != RT_SIZE; i++) {
uint32_t index = uint32_t_msh(rt[i], BITS, seed);
if (buf[index]) {
if (i > max) {
// printf("\nMax: %llu\n", i);
max = i;
}
clash = true;
break;
} else {
buf[index] = true;
}
}
// check for collisions
for (size_t i = 0; i != RT_SIZE; i++) {
uint32_t index = uint32_t_msh(rt[i], BITS, seed);
if (buf[index]) {
if (i > max) {
// printf("\nMax: %llu\n", i);
max = i;
}
clash = true;
break;
}
else {
buf[index] = true;
}
}
// exit if non-clashing seed found
if (!clash) {
break;
}
// seed must be odd
seed += 2;
} while (seed != UINT32_MAX); // is odd, so will be hit
// exit if non-clashing seed found
if (!clash) {
break;
}
if (!clash) {
printf("\nSeed found: %u", seed);
for (size_t i = 0; i != RT_SIZE; i++) {
char name[5];
memcpy(name, &rt[i], sizeof(uint32_t));
name[4] = '\0';
uint32_t index = uint32_t_msh(rt[i], BITS, seed);
if (i % PER_LINE == 0)
printf("\n");
else
printf(" ");
printf("RT_%s = %3u,", name, index);
}
} else {
printf("Seed not found. Max: %llu\n", max);
}
// seed must be odd
seed += 2;
} while (seed != UINT32_MAX); // is odd, so will be hit
return 0;
if (!clash) {
printf("\nSeed found: %u", seed);
for (size_t i = 0; i != RT_SIZE; i++) {
char name[5];
memcpy(name, &rt[i], sizeof(uint32_t));
name[4] = '\0';
uint32_t index = uint32_t_msh(rt[i], BITS, seed);
if (i % PER_LINE == 0)
printf("\n");
else
printf(" ");
printf("RT_%s = %3u,", name, index);
}
}
else {
printf("Seed not found. Max: %llu\n", max);
}
return 0;
}