Giter VIP home page Giter VIP logo

sat-sudoku's Introduction

SAT Sudoku solver

This is a Sudoku solver based on PicoSAT, using the python wrapper pycosat. See more about SAT here.

Four constraints are applied:

  • Each cell is filled with one and only one digit from 1 to 9.
  • Each row contains all nine different digits.
  • Each column contains all nine different digits.
  • Each sub-box contains all nine different digits.

Install

python3 -m virtualenv rt
. rt/bin/activate
pip install -r requirements.txt

To use Python implementation

Change the main_encc() at the last line of sudoku.py to main_enc().

To use C++ implementation

Comment out zero or more macro definitions in define_macros keyword argument in setup.py to redefine macros in C++ implementation. Then

python setup.py build_ext -if

How to use

python sudoku.py SUDOKU_BOARD_FILE OUTPUT_FILE

An example of SUDOKU_BOARD_FILE is example-boards/board.txt.

To use different sudoku encoding

Change

cclauses = encc.extended_encode(board)

to, e.g.,

cclauses = encc.minimal_encode(board)

in sudoku.py.

Related project

Another SAT-based sudoku solver can be found in here, which seems to use the minimal encoding as found in this repo.

References

sat-sudoku's People

Contributors

kkew3 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.