Box and band view using digits, mini rows mini columns patterns.This is an important topic for the code written in my 2 variants.
Let’s call digit pattern a 9 bits field where the bit “n” is set to 1 giving
- Code: Select all
1 1.........
2 .1........
...
8 ........1.
9 .........1
A mini row as a mini column will be a bit field with three digits sets to 1 eg :
- Code: Select all
147 1..4..7..
A box is entirely defined by the six bit fields 3 mini rows + 6 mini columns.
Each of the 3 mini rows and mini columns contain the 9 digits patterns
For each cell the digit pattern is defined using the right mini row and the right mini columns eg
- Code: Select all
Box mini rows mini columns
123 111...... 1..1..1..
456 ...111... .1..1..1.
789 ......111 ..1..1..1
- Code: Select all
Cell r2c2 mini row 2 mini column 2
...111... &
.1..1..1. =
....1.... pattern for digit 5
This view on a box is of high interest:
It can be extended to a band, a stack and the 9 boxes of a grid
Nearly all required operations are done with one native instruction in the x86 set of instructions.
Eg
compare 2 mini rows ignoring the order of the digits
find the common digits in 2 mini rows/mini columns
count such common digits
switch form the digit pattern to the digit 1-9 and reverse ...
Mini rows and mini columns are just exchanged in the valid permutations of a box (6x6 permutations).
In the former post is a table of the 416 min lexical bands 1. At the end is attached the count of different mini columns patterns and the count of mini columns seen three or two times, one example of a property easy to check.
Mini patterns and min lexical bands.Just considering the mini rows patterns, many permutations can be discarded and some results can appear quickly.
The top part of the list of bands is made of three repetitive mini rows patterns “123” “456 “789”.
The rest has two common digits in the mini row 2 and the mini row 4, so having the first box and the rows defined, only one stack perm is possible for the 2 other stacks. The 2 common digits leave only one place for columns 3,6 and 7.
Selecting and optimizing the use of such properties is the way used here to find quickly the band index;
In a very small number of cases, relying on properties invariant in the permutations, we get immediately the band index:
. Band 1 (index 0) is the only one having 3 repetitive mini rows and 3 repetitive columns.
. band index 412 has also 3 repetitive mini columns, but no repetitive mini row
.....
But in most cases, these invariant properties will create subgroups of possible band indexes, so the analysis of permutations is unavoidable. Even if the index can be given, the mapping, if needed, will require the use of several permutations.
In the search of min lexical solution grids and in the virtual catalog, using partly this process, each band/stack must be studied, but the main point is to know if a given band/stack has an index lower equal or higher than the index of the first band.
. if the index if lower, the solution grid studied { partial (band2 or band 3) or filled (stacks) } is not lexically minimal
. if the index is higher, in most cases, nothing is expected
. if the index is equal, then the new band/stack is a potential start for a lower permutation and the mapping to the min lexical morph is needed
Relying on the list of min lexical solution grids, we have many ways to cut in the classical process requiring doing all permutations and comparing the entire solution grid. Most of them are not yet implemented in the old code and in the first draft of the second variant.
Here are some of the properties to use.
Minimum and maximum possible index of the bandThis is easy to understand using mini rows and mini columns properties.
Repetitive mini rowIf we find 2 repetitive mini rows, as already seen, the band has 3 repetitive mini rows and the final index is in the range 0-30. Any solution grid with a first band having an index >30 and another band or any stack with an index <=30 is not minimal.
Similar exclusions can come from the mini columns analysis.
Six mini columnsIn the list given in the second post, we can extract these 4 min lexical bands 1.
- Code: Select all
123 456 789 _ 457 389 612 _ 896 127 345 _ 397 6 0 3
123 456 789 _ 457 389 612 _ 896 172 345 _ 399 6 0 3
123 456 789 _ 457 389 612 _ 896 217 345 _ 401 6 0 3
123 456 789 _ 457 389 612 _ 896 271 345 _ 403 6 0 3
If we get a solution grid with no repetitive mini row and a count of 6 different mini columns, the minimal morph of this solution grid is one of the four.
So the solution grid will have an index in the range 397 – 403, ignored in most cases , cancelling the expansion if the band1 has an index > 403.
But we can make other remarks about this family:
No permutation can come with a start 123456789_ 457_ 1 or 2. Our list of min lexical bands is exhaustive.
The start 123456789_ 457_ 893 can not be excluded, but can be skipped, it would not be a minimal morph.
First hitThe first hit on a member of the list is the index searched. No permutation will produce a lower index.
Degressive value in r2c4 and maximum possible index.We consider now the subgroup of solution grids having 8 different mini columns. Here below 3 solution grids taken in the list of the post 2, with different values in r2c4.
- Code: Select all
123 456 789 _ 457 189 236 _ 689 237 154 _ 32 8 0 1
123 456 789 _ 457 289 613 _ 869 713 245 _ 366 8 0 1
123 456 789 _ 457 389 612 _ 896 172 354 _ 400 8 0 1
For each value in r2 c4, we have a lower and a higher possible index
- Code: Select all
1 32 346
2 361 387
3 398 410
As in the previous example, we can ignore permutations 1234567899_457_>3, They would not be minimal.
If we see a permutation with 2r2c4, we are sure to have a min lexical solution with 2 r2c4 or 1 r2c4. Having one permutation with 2r2c4, a permutation with 3 r2c cannot be minimal. This limits the highest index to 387, but the lowest can still be 32.
If we get a permutation with 1 r2c4, the min lexical must have 1 r2c4 and be one of the reduced list of known bands 1. Then the index will be in the range 32 346.
More reductions of the rangeJust considering r2c4 and the mini columns count, we still have a wide range of possible indexes with 1r2c4;2r2c4 and 8/9 different mini columns.
All these minimal bands have 89 in r2c5,r2c6. A similar reduction of the range is possible using the next cells r2c7,r2c8 ...