Giter VIP home page Giter VIP logo

sudoku-solver's Introduction

Sudoku AI Solver


This program uses Constraint Propagation, Backtracking Search, Forward Checking, MRV and Degree Heuristics to solve 9 x 9 Sudoku puzzles.
This program will do:

  1. Read Sudoku problems from file
  2. Solve problem via:
    • Constraint Propagation (use AC-3 algorithm)
      Remove all non-valid domain values given the initial sudoku layout
    • Backtracking Search (BT) extended by Forward Checking (FC) + MRV and Degree Heuristics
      Traverse blank cells to assign possible value in its domain. After a blank cell is assigned a value, verify the validity by forward checking. If the one conflicts with another value, go back to previous state and try another possible value. Heuristics are used to determine which blank cell to assign next.
  3. Display solution to the terminal


Build Instructions

Prepare Input File

  • Name input file as sudoku-puzzles.csv
  • 9 x 9 sudoku board is represented as 81 consecutive numbers
  • Format sudoku puzzles as [puzzle] {[puzzle solution]}
    • 0 represents an empty cell
    • puzzle solution is optional (if solution is provided, program will display solution at the end)
    • multiple puzzles can be added to input file (in that case, program will select puzzle randomly)

Example with solution
030604250200300100009250008000700090902005031740100006090070604001060000526800903 837614259254398167619257348183726495962485731745139826398572614471963582526841973

Example without solution 008605010000000420010700000000010530000000080300800009040900000097001600030024000

Run Program
Type command python3 solver.py to start program


Output Example

output-example


sudoku-solver's People

Contributors

joenho avatar

Stargazers

 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.