14 inline void swap(T &a, T &b)
24 uint64_t multiplier = 1;
25 for (
int i = 0; i < distinctSize; i++)
28 unsigned int tmp2 = locs[i];
30 result2 += (tmp-i)*multiplier;
31 multiplier *= (puzzleSize-i);
33 if (tmp2 < puzzleSize)
35 swap(locs[i], locs[dual[i]]);
36 swap(dual[tmp2], dual[i]);
46 uint64_t multiplier = 1;
47 for (
int i = 0; i < distinctSize; i++)
50 unsigned int tmp2 = locs[i];
52 result2 += (tmp-i)*multiplier;
53 multiplier *= (puzzleSize-i);
55 if (tmp2 < puzzleSize)
57 swap(locs[i], locs[dual[i]]);
58 swap(dual[tmp2], dual[i]);
72 for (
int x = 0; x < puzzleSize; x++)
75 int last = (puzzleSize-distinctSize);
76 memset(puzzle, 0xFF, puzzleSize*
sizeof(puzzle[0]));
78 for (
int i = 0; i < distinctSize; i++)
80 swap(dual[i+hash%(puzzleSize-i)], dual[i]);
81 hash = hash/(puzzleSize-i);