Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

General enhancement and modernization. #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

brotskydotcom
Copy link

  1. Move to Python 3 (3.7 with type annotations) and pipenv (for dependencies).
  2. Support 4x4, 9x9, and 16x16 puzzles.
  3. Increase efficiency through caching of cell contexts, and restricting the solver to only trying possible values.
  4. Use Click to give the top-level script a better CLI.
  5. Provide for JSON output to allow programmatic post-processing.
  6. Allow for generation of multiple puzzles in a single run.

1. Move to Python 3 (3.7 with type annotations) and pipenv (for dependencies).
2. Support 4x4, 9x9, and 16x16 puzzles.
3. Increase efficiency through caching of cell contexts, and restricting the solver to only trying possible values.
4. Use [Click](https://click.palletsprojects.com/en/7.x/) to give the top-level script a better CLI.
5. Provide for JSON output to allow programmatic post-processing.
6. Allow for generation of multiple puzzles in a single run.
1. Make the board indexes into lists, so they are ordered and direct access.
2. Fix solver bugs.
3. Tweak all the thresholds after a lot of empirical testing with different puzzle sizes.
4. Extend the CLI to allow access to the solver.
5. Move the CLI into the module
6. Move to setuptools for easier documentation/packaging/installation.
7. Update the .gitignore file
@RutledgePaulV
Copy link
Owner

Hi Daniel,

Thanks for your efforts here and for making a PR - I'm glad you were able to use my library as the foundation for some of the stuff you're doing. I wanted to let you know I'm aware this is here and I've considered the changes.

I'm torn because this was always meant to be more of a reference implementation (clean but not particularly fast or featureful). The changes you've made seem to suggest turning it into a more robust tool to actually produce puzzles in a variety of sizes and formats for use.

If you continue on the tool route it seems like logical next steps would be to make it available as a package and whatnot but I'm not interested in maintaining and distributing a sudoku tool. I'm also largely rooted in the Clojure community these days and so not doing much with Python.

All this to say - thanks for the effort and for contributing, but I'm too invested in other things to maintain a sudoku generator tool. If you'd like to promote your own fork with these changes and take it in that direction you have my full support!

@brotskydotcom
Copy link
Author

Hi Paul,

Thanks for the thoughtful review, and for having created such a good foundation. I actually haven't changed any of your core logic at all; all the changes I made were just motivated by (1) making sure I understand how your code worked, (2) making sure it could generate 4x4 as well as 9x9 puzzles, since it's really 4x4 puzzles I need for my other project, and (3) lashing it up so that I can invoke it programmatically. So your excellent "reference implementation" still survives, at least I hope it does :).

I completely understand your rationale for not taking the pull request. I also don't plan to maintain a sudoku tool (or publish it), but since I'm planning to use it in another (eventually) published project I will go ahead and keep it available for people in my repo.

Thanks again for the leg up. -d.

The brute-force solver was just too slow for 16x16 puzzles.  So I integrated the Peter Norvik solver, which takes a few seconds on puzzles of this size.

I also did a bunch of naming and cleanup, and got rid of user-submitted puzzles to start generation from.
We now use separate thresholds for each puzzle size, allowing us to use specific cutoffs rather than percentages.

I also did more analysis of how the square removal algorithm works, and improved the doc on that.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants