This is how I did the 416-grouping in Guenters program sudoku416:

I run through a subset of bands from which I know there will always be a representative for each class. The classes are named in the order their first element is found.

I restrict down to the following set of bands:

- Code: Select all
`123 ... ...`

456 12x ...

789 ... 12y

On top level, I run through the choices for (x,y). First x=y=3, then x runs from 7 to 9 and y runs from 4 to 6.

With x and y, the elements in every minirow are given. I then run through the 6^4 different ways to permute the elements in the ...-minirows above. The minirows are handled in the following order:

First row 3, box 2

Then row 2, box 3

Then row 1, box 2

Then row 1, box 3

Just to make the mess complete, the permutations are done in the following order for each case:

123, 321, 312, 213, 231, 132

This is because I can then use the following simple code to run through all permutations:

- Code: Select all
`int permSet[3]; // Set to be permuted`

#define SWAP(A,B) { int t=A; A=B; B=t; }

static void runThroughPermutations() {

for (int i=0; i<6; i++) {

<insert code to use for each permutation>

// Permute

SWAP (permSet[i%2], permSet[2]);

}

}

The algorithm was one of my first contributions here. It was not meant to give an intuitive lexiographical ordering of the bands or the 416 classes, just to give them a unique index inside a program.

I see today ways to get the 416-index much faster.

If this is of any interrest, I had a program

November 2005 that ran through all equivalence classes of Sudoku grids, when I confirmed the number 5472730538. One of the tools I used, was to get the 416-index of bands and stacks, as Guenters sudoku416-program does for a given list. I did indeed find several cases where essentially different Sudoku grids had the same 416-index tripple for bands and stacks.