Dear
Mladen Dobrichev,
I'm sorry that the ".docx" file type, a Microsoft creation, has caused a few problems.
A few years ago I wrote a 'C++' program to convert both partial and full Soduko grids to minlex form. About three months ago, to my chagrin and edification, you brought to my attention a logic error in the part of the code that deals with partial grids. I decided to re-write the whole thing. In doing so, I re-visited the full grid problem.
Let me address questions dealing with converting
full solution grids to minlex form.
1. Yes, my approach is to score row pairs, saving only the best for futher processing.
First, compute the puzzle transpose, so that chutes can be treated as three extra bands.
Next, compute the "rank" of each pair of rows within a band. Since the rank of row-x vs. row-y is the same as row-y vs. row-x, only 18 routine calls need be made. Only row pairs of lowest rank need be considered as candidates for the first two rows in the minlex matrix.
2. If row-x and row-y are one of the candidate pairs, either order could be correct, and both choices must be pursued.
3. Suppose we wish to pursue row-x vs. row-y. Since we know the rank of row-x vs. row-y, we also know:
a) exactly what row-1 and row-2 of the minlex matrix will be. (Our goal.)
b) the "#Ways" that row-x/row-y can be transformed into our goal.
c) the cycle structure of our goal and the cycle structure of row-x/row-y.
d) how to quickly generate a
dual key set for row-y vs. row-x using a
known permutation.
There is a way (not detailed in the reference, because of complexity) to
generate a set of keys which transform row-x/row-y to our goal. Although row-y/row-x keys could be generated using the same scheme, it is much faster to generate the
dual key set from the one we already have, using a
known permutation.
4. We are really flying now. Row-1 and row-2 are filled. We know the entire 9-long "column" key and the substututions needed to make row-1 equal to '123456789'. So we just plop-in row-3 with the only remaining row from the xy-band and "score". The "score" is whatever row-3 turns out to be. At this point, the number of competing answers will
usually be reduced to just one.
5. To order minlex rows 4 thru 9, we need only to examine the translated (substituted) digits in the first column in the rows of the two bands we have not already used (we should know whether we are dealing with the original or its transpose).
Here follows some of your statements/questions and my comments.
*** In Table A there is a column for #Ways to obtain the same result by different permutations and relabeling. It is automorphism level. Several permutations result to indistinguishable results, but this is true only in the context of these two rows.
--- Sorry, I don't understand the question.
*** Do you take into account that for the third row (and later for the next 2 bands) you must check all these ways?
--- After the initial 18 "checks", no further checks are made. The computation of "rank" is just to quickly find candidates for minlex row-1 and row-2.
*** From other point of view, it is known that there are exactly 416 essentially different bands, and you group them into 14 classes.
--- When I was generating the min and max lists, I really didn't consider that grids could also be classified by minimum or maximum rank, though what you say is true. I just wanted to see if I could do it.
*** A fast normalization algorithm could be useful for generation of all essentially different grids.
--- The algorithm I used to normalize full grids is certainly fast, but it may not be fast enough for your proposed applications.
*** Finally, some words about the ideal normalization algorithm. It must be capable to perform the operation in 2 steps: obtain the "transformation(s)", then apply the transformation(s) to the given grid or to a subgrid (puzzle). For grids with automorphism level > 1 there must be a list of valid transformations, up to 648. It must be capable to perform reverse transformations. It must be thread-safe, which is not the case in gsf's implementation of your puzzle minlex algorithm (the static buffer for the stacks).
--- I do not know the meaning of: 1) "automorphism level > 1" or 2) "reverse transformation" or 3) "thread-safe".
Your mentioned a "list of valid transformations, up to 648". I stated earlier that after row-3 is added to the minlex matrix that the number of competing answers will usually be reduced to just one. In one very special case, the number of competing answers is 648, and that is when the the first three rows of the minlex matrix are:
- Code: Select all
123 456 789
456 789 123
789 123 456
--- The updated version of the routine will be in 'C', and the normalization of partial puzzles will be about the same, hopefully without the logic bug. I will email to you some 'C' code showing how I compute "rank".
Cheers,
holdout