kaityo256 / minlex

Show the minlex canonical order form of the given Sudoku grid.
MIT License
4 stars 2 forks source link

Minlex Canonical Order Form of Sudoku Grids

Summary

Show the canonical form of the sudoku grid by the minlex order. It transforms the input sudoku grid so that the generated 81-digits number becomes the smallest.

Usage

$ cat sample.txt
009000000500080200400020090010300060080600007050000900608730000000106500000040700
400030100908000700000000096040100000070000009500200070107980000020005080000004600
000007009003040081000050720200030090004000016905100000407300000090000600000004000
(snip)
703800060090060400400100000300910000000200019080005000000600300007003040000000970
030002040200000600104006009400010000000500000009000480000703006600050012020000800
300000068001080000906300100000670800007004000002000030010090700000002005050000042

$ make
g++ -Ofast -std=c++11 -march=native -Wall -Wextra minlex.cpp -o minlex

$ ./minlex sample.txt
000000001000002030014050200000000467300048000700200000003000000106000093980075000
000000012000003400056000700000040800001072500820000060000085009008700040700900000
000000001000012030004350060000070040053004000600000300028701000060000009107900000
(snip)
000000001002013000040250006000300070004000600680004109001000080030500000250000300
000000001000002030024050000002600700080007000500023800040700000703008010800000609
000000012000034000056000307000405080010009070800060003009500000600020800700000001

License

All source codes in this repository are licensed under the MIT License.