81 * 9 = 729 indexes, each of size 5,472,730,538 - if that is more clear. Waste of memory.
The topmost 2 and bottommost 2 grids of the whole catalog, with your puzzle at the bottom, are
- Code: Select all
123456789456789123789123456214365897365897214897214365531642978642978531978531642
123456789456789123789123456214365897365897214897214365531642978648971532972538641
...
123456789457389621896217354268741593745893162931625847382164975574938216619572438
123456789457893612986217354274538196531964827698721435342685971715349268869172543
.............................................6......3.....8......5........9.72...
In penclimarks representation
- Code: Select all
1.........2.........3.........4.........5.........6.........7.........8.........9...4.........5.........6.........7.........8.........91.........2.........3............7.........8.........91.........2.........3.........4.........5.........6....2.......1...........4.......3...........6.......5...........8.........9......7....3...........6.......5...........8.........9......7...2.......1...........4............8.........9......7...2.......1...........4.......3...........6.......5........5......3......1.............6......4......2...............9......7.........8......6......4......2...............9......7.........8.....5......3......1................9......7.........8.....5......3......1.............6......4......2.......
1.........2.........3.........4.........5.........6.........7.........8.........9...4.........5.........6.........7.........8.........91.........2.........3............7.........8.........91.........2.........3.........4.........5.........6....2.......1...........4.......3...........6.......5...........8.........9......7....3...........6.......5...........8.........9......7...2.......1...........4............8.........9......7...2.......1...........4.......3...........6.......5........5......3......1.............6......4......2...............9......7.........8......6......4............8.........9......7..1............5......3.......2...............9......7...2...........5......3.............8......6......4.....1........
...
1.........2.........3.........4.........5.........6.........7.........8.........9...4.........5..........7....3.............8.........9.....6....2.......1...............8.........9.....6....2.......1..............7....3..........5.......4......2............6..........8.......7.....4.....1............5............9..3............7.....4.........5...........8.........9..3......1.............6....2...............9..3......1.............6....2...........5...........8....4...........7....3.............8..2.......1.............6......4.............9......7......5........5..........7.....4.............9..3.............8..2.......1.............6........6...1................9....5..........7...2..........4.......3.............8.
1.........2.........3.........4.........5.........6.........7.........8.........9...4.........5..........7.........8.........9..3...........6...1.........2...............9.......8......6....2.......1..............7....3..........5.......4......2.............7.....4.........5......3.............8.1................9.....6.......5......3......1................9.....6......4............8..2.............7.......6...........9.......8.......7...2.......1...........4.......3..........5......3.........4......2............6..........8.....5............9......7..1..............7..1............5......3.........4.............9.2............6..........8........8......6...........91..............7...2...........5.......4.......3......
.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________.________._____________6___.________.________.________.________.________.__________3______.________.________.________.________._______________8_.________.________.________.________.________.____________5____.________.________.________.________.________.________.________.________________9.______________7___2_______.________.________.________
123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789.....6...123456789123456789123456789123456789123456789123456789..3......123456789123456789123456789123456789123456789.......8.123456789123456789123456789123456789123456789123456789....5....123456789123456789123456789123456789123456789123456789123456789123456789........9123456789......7...2.......123456789123456789123456789
Index values for your givens for the first 2 and last 2 grids. 1=matches, 0=doesn't match. Only they are using in finding all solutions.
- Code: Select all
6 00...01
3 00...01
8 00...01
5 00...01
9 00...11
7 00...11
2 00...11
In the above table you should find all columns having 1 for all rows. In your case this is the last column = last grid.
Naive approach is doing bitwise AND on the uncompressed indexes of interest.
Better approach is to keep indexes in compressed form, start from root=grid0, loop trough indexes by leaving the root the same if index matches, or incrementing the root to the next matched grid for the current index.
If all indexes match particular root, then it is a solution - export it and increment root. Continue until root reaches end of some index.
At the moment I have no solution how to keep the indexes in compressed form efficiently. The only question an index should be able to answer is "Give me your first match for grid number >= N".