Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canonicalization #5

Open
2 of 3 tasks
Emerentius opened this issue Jun 10, 2018 · 2 comments
Open
2 of 3 tasks

Canonicalization #5

Emerentius opened this issue Jun 10, 2018 · 2 comments

Comments

@Emerentius
Copy link
Owner

Emerentius commented Jun 10, 2018

Sudokus can be transformed in ways that do not affect the number of solutions or the applicability of solution strategies and thus their difficulty. One example is relabeling by switching 1 and 2 everywhere. The crate already contains a shuffle function that performs such transformations in a random manner. It should also contain a function to map all equivalent sudokus to the same sudoku, the canonical form.

Todo:
Canonicalizations for

  • solved sudokus
  • unsolved sudokus based on their (unique) solution
  • unsolved sudokus, preserving the pattern of clues
@david-fong
Copy link

I'm currently doing some work on a related problem: Checking if two Sudokus are equivalent. Perhaps the thinking can be useful? here it is

@Emerentius
Copy link
Owner Author

I must admit I had trouble trying to understand the approach you're taking there (and it seems the link is dead now). I think the algorithm was for fully solved sudokus?
For both solved and uniquely solvable sudokus I already have a canonicalization implementation that is apparently decently fast, >20,000 sudokus/s on my laptop (I thought it was only ~1k/s).

I don't have a good idea of what to do for unsolved sudokus that have zero or more than one solution. Neither do I have a good approach for a pattern preserving canonicalization.

My current algorithm uses the lexicographically minimum sudoku as canonical form and uses the minlex property to cut down the search space substantially.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants