Git Product home page Git Product logo

sudoku-solver's Introduction

Artificial Intelligence Nanodegree

Introductory Project: Diagonal Sudoku Solver

How do we use constraint propagation to solve the naked twins problem?

Constraint Propagation is all about using local constraints in a space to dramatically reduce the search space. In the case of Naked Twins, the constraint is that if the same box value pair appears in the column unit or row unit, then all other boxes in the square unit cannot contain the pair of values in those two boxes. As we enforce each constraint, we see that it introduces new constraints for other parts of the board that can help us further reduce the number of possibilities.

How do we use constraint propagation to solve the diagonal sudoku problem?

Constraint Propagation is all about using local constraints in a space to dramatically reduce the search space. In the case of Diagonal Sudoku, among the two main diagonals, the numbers 1 to 9 should all appear exactly once. As we enforce each constraint, we see that all other boxes on the diagonal cannot contain any values previously seen.

Install

This project requires Python 3. You'll also want to download Anaconda in order to reproduce the results.

Optional: Pygame

Optionally, you can also install pygame if you want to see your visualization. Please see how to download pygame here.

Code

  • solutions.py - Sudoku solver.
  • solution_test.py - You can test your solution by running python solution_test.py.
  • PySudoku.py - This is code for visualizing Sudoku solver.
  • visualize.py - This is code for visualizing Sudoku solver.

Here is a screenshot of a solved puzzle: Solved Puzzle

Visualizing

To visualize your solution, please only assign values to the values_dict using the assign_values function provided in function.py

Data

The data consists of a text file of diagonal sudokus for you to solve.

sudoku-solver's People

Contributors

donigian avatar

Watchers

 avatar  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.