Hi, colleagues!
Does anyone know the way to canonicalize given pattern? I use gsf's "sudoku" tool to canonicalize puzzles, but I don't know how to canonicalize patterns by means of this tool. Maybe any else tool is available. Please, help.
Serg
Serg wrote:Does anyone know the way to canonicalize given pattern? I use gsf's "sudoku" tool to canonicalize puzzles, but I don't know how to canonicalize patterns by means of this tool.
champagne wrote:Hi Serg
I am sure gsf or ronk knows how to do that using gsf's program
I am suspecting gridchecker (contatct dobrichev through pm) can do it as well, but I only used the "pattern mode" option
I have also a canonicalization process, delivering a maxtext canonical form performing well.
If you have no other answer or if you need a high speed process, i can arrange to give you the exec file (PC) and the command line to use
champagne
ronk wrote:Serg wrote:Does anyone know the way to canonicalize given pattern? I use gsf's "sudoku" tool to canonicalize puzzles, but I don't know how to canonicalize patterns by means of this tool.
gsfsudoku -f%#xc file.dat
... where file.dat contains standard line-formatted puzzles. "Comments" following the puzzle must be removed. Appending these comments to each canonicalized pattern is a bit tougher, but can usually be done too.
Serg wrote:Format like "XXX.....X...X ..." sudoku tool doesn't understand.
gsf wrote: #X: Like #x, but list original puzzle in row order minlex canonical order.
gsf wrote:#P: Row order pattern minlex canonical.
#!exemplar
.................X..X..X...................XX..X..X...XXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXX.................X..X..X..................XX...X..X...
.................X..X..X.................X.....X....XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
.................X..X..X..........XX.....X.....X......XXXXXXXXXXXXXXXXXXXXXXXXXXX
.................X..X..X...................XX..X..X...XXXXXXXXXXXXXXXXXXXXXXXXXXX
.................X..X..X..................XX...X..X...XXXXXXXXXXXXXXXXXXXXXXXXXXX
.................X..X..X.................X.....X....XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
.................X..X..X..........XX.....X.....X......XXXXXXXXXXXXXXXXXXXXXXXXXXX
dobrichev wrote:gridchecker --similar --subcanon < in > out
or
gridchecker --similar --puzzles in --mspuzzles out
The second command removes duplicates and orders the list. Applicable for several millions of puzzles in the list.
Input is '11...11.1.1', just use the same number for all givens and 0 or not a number for non-givens. Extra chars are ignored.
Output is '1' and '.'.
dobrichev wrote:BTW it was fun this night near Sofia. 19 earthquakes starting with 5.7 at 3:00AM and still counting.
random puzzle - test.txt
9..46....5.......714..5..9.6..8....9..2...5..8....1..4.6..8..453.......1....72..8
minlex pattern
sudoku-64 -f%#xc test.txt
........X..X..X....X.XXXXX.........X..X..X...XXX.X.XX....X...X.X.....X..X.XX.X...
puzzle with minlex pattern
sudoku-64 -f%#Xc test.txt > test1.txt
........2..6..4....3.95186.........5..4..9...815.7.49....4...8.2.....1..7.86.5...
puzzle with minlex pattern with minlex clues
sudoku-64 -f%#Pc test1.txt
000000001002003000040567820000000006003005000876090350000300080100000700908206000
minlex puzzle
sudoku-64 -f%#mc test.txt
000000001002003000040561230000000007003008000215900860000070050300000600801046000
puzzle with representative from its minlex solution grid
sudoku-64 -f%#0c test.txt
020450700000100006089200000200300007000004090001500002000800004570000003040030501
gridchecker --similar --subcanon < test.txt > test2.txt
9..46....5.......714..5..9.6..8....9..2...5..8....1..4.6..8..453.......1....72..8 ........1..2..3....4.56123.........7..3..8...2159..86.....7..5.3.....6..8.1.46...
.2..7.1..5....4..3..........7....82...13........5.....6...8..7.3..9............8.
.4..7.1..5....6..3..........7....82...13........5.....6...8..7.3..2............9.
.4..7.1..5....6..3..........7....82...83........5.....6...8..7.3..2............4.
.8..4.1..5....6..3..........4....82...13........5.....6...8..7.3..2............4.
.8..4.1..5....7..3..........4....82...13........5.....6...8..7.3..2............4.
.8..7.1..5....4..3..........7....28...13........5.....6...8..7.3..2............2.
.8..7.1..5....4..3..........7....82...13........5.....6...2..7.3..4............8.
gridchecker --similar --subcanon < test3.txt > test3a.txt
...........1..2..3.4..5..6.......1...6.47....5.....2.....7.......2...8....96...7.
...........1..2..3.4..5..6.......1...6.78....5.....2.....9.......2...7....36...8.
...........1..2..3.4..5..6.......1...5...72...6.8........4.......2...8.77..6.....
...........1..2..3.4..5..6.......1....2.4.7..8...6.........18.25........6..3.....
...........1..2..3.4..5..6.......1....2.7.4..8...6.........18.25........6..3.....
...........1..2..3.4..5..6.......1...6.47....5.....2.....7.......2...7....86...4.
...........1..2..3.4..5..6.......1...6.5......7...82.....4.......2...8.13..6..... *** same as below
sudoku-64 -f%#mc test3.txt
000000000001002003040050060000000100060470000500000200000700000002000800009600070
000000000001002003040050060000000100060780000500000200000900000002000700003600080
000000000001002003040050060000000100050007200060800000000400000002000807700600000
000000000001002003040050060000000100002040700800060000000001802500000000600300000
000000000001002003040050060000000100002070400800060000000001802500000000600300000
000000000001002003040050060000000100060470000500000200000700000002000700008600040
000000000001002003040050060000000100060500000070008200000400000002000801300600000 *** same as above
sudoku-64 -f%#Xc test3.txt
...........1..2..7.3..5..4.......5.....1..3..2.8..7.......3.9..8........7...6...8
...........1..4..7.3..5..6.......5.....1..3..2.8..7.......3.2..9........7...6...8
...........1..4..7.3..5..6.......5.....8..3..2.8..7.......3.2..4........7...6...8
...........1..8..4.3..5..6.......5.....1..3..2.8..4.......3.2..4........7...6...8
...........1..8..4.3..5..7.......5.....1..3..2.8..4.......3.2..4........7...6...8
...........1..8..7.3..5..4.......5.....1..3..8.2..7.......3.2..2........7...6...8
...........1..8..7.3..5..4.......5.....1..3..2.8..7.......3.4..8........7...6...2
sudoku-64 -f%#Xc test3.txt > test4.txt
sudoku-64 -f%#Pc test4.txt
000000000001002003040050060000000500000100400207003000000040800700000000300090007
000000000001002003040050060000000500000100400708003000000040700900000000300060008
000000000001002003040050060000000500000700400807003000000040800200000000300060007
000000000001002003040050060000000500000100400702003000000040700300000000800060002
000000000001002003040050060000000500000100400702003000000040700300000000600080002
000000000001002003040050060000000500000100400207003000000040700700000000300080002
000000000001002003040050060000000500000100400702003000000040600200000000300080007
...........1..1..1.1..1..1.......1.....1..1..1.1..1.......1.1..1........1...1...1
coloin wrote:
- Code: Select all
gridchecker --similar --subcanon < test3.txt > test3a.txt
...........1..2..3.4..5..6.......1...6.47....5.....2.....7.......2...8....96...7.
...........1..2..3.4..5..6.......1...6.78....5.....2.....9.......2...7....36...8.
...........1..2..3.4..5..6.......1...5...72...6.8........4.......2...8.77..6.....
...........1..2..3.4..5..6.......1....2.4.7..8...6.........18.25........6..3.....
...........1..2..3.4..5..6.......1....2.7.4..8...6.........18.25........6..3.....
...........1..2..3.4..5..6.......1...6.47....5.....2.....7.......2...7....86...4.
...........1..2..3.4..5..6.......1...6.5......7...82.....4.......2...8.13..6.....
N1 N3
+-----+-----+-----+ +-----+-----+-----+
|. . .|. . .|. . .| |. . .|. . .|. . .|
|. . 1|. . 2|. . 3| |. . 1|. . 2|. . 3|
|. 4 .|. 5 .|. 6 .| |. 4 .|. 5 .|. 6 .|
+-----+-----+-----+ +-----+-----+-----+
|. . .|. . .|1 . .| |. . .|. . .|1 . .|
|. 6 .|4 7 .|. . .| |. 5 .|. . 7|2 . .|
|5 . .|. . .|2 . .| |. 6 .|8 . .|. . .|
+-----+-----+-----+ +-----+-----+-----+
|. . .|7 . .|. . .| |. . .|4 . .|. . .|
|. . 2|. . .|8 . .| |. . 2|. . .|8 . 7|
|. . 9|6 . .|. 7 .| |7 . .|6 . .|. . .|
+-----+-----+-----+ +-----+-----+-----+
N3: swap rows r2/r3 and columns c2/c3, c5/c6, c8/c9
+-----+-----+-----+
|. . .|. . .|. . .|
|. . 4|. . 5|. . 6|
|. 1 .|. 2 .|. 3 .|
+-----+-----+-----+
|. . .|. . .|1 . .|
|. . 5|. 7 .|2 . .|
|. . 6|8 . .|. . .|
+-----+-----+-----+
|. . .|4 . .|. . .|
|. 2 .|. . .|8 7 .|
|7 . .|6 . .|. . .|
+-----+-----+-----+
N3: swap stacks B258/B369
+-----+-----+-----+
|. . .|. . .|. . .|
|. . 4|. . 6|. . 5|
|. 1 .|. 3 .|. 2 .|
+-----+-----+-----+
|. . .|1 . .|. . .|
|. . 5|2 . .|. 7 .|
|. . 6|. . .|8 . .|
+-----+-----+-----+
|. . .|. . .|4 . .|
|. 2 .|8 7 .|. . .|
|7 . .|. . .|6 . .|
+-----+-----+-----+
N3: swap bands B456/B789
+-----+-----+-----+
|. . .|. . .|. . .|
|. . 4|. . 6|. . 5|
|. 1 .|. 3 .|. 2 .|
+-----+-----+-----+
|. . .|. . .|4 . .|
|. 2 .|8 7 .|. . .|
|7 . .|. . .|6 . .|
+-----+-----+-----+
|. . .|1 . .|. . .|
|. . 5|2 . .|. 7 .|
|. . 6|. . .|8 . .|
+-----+-----+-----+
N3: relabel: 4 -> 1, 6 -> 2, 5 -> 3, 1 -> 4, 3 -> 5, 2 -> 6, 8 -> 7, 7 -> 8
+-----+-----+-----+
|. . .|. . .|. . .|
|. . 1|. . 2|. . 3|
|. 4 .|. 5 .|. 6 .|
+-----+-----+-----+
|. . .|. . .|1 . .|
|. 6 .|7 8 .|. . .|
|8 . .|. . .|2 . .|
+-----+-----+-----+
|. . .|4 . .|. . .|
|. . 3|6 . .|. 8 .|
|. . 2|. . .|7 . .|
+-----+-----+-----+