Giter Site home page Giter Site logo

aind-sudoku's Introduction

Artificial Intelligence Nanodegree

Introductory Project: Diagonal Sudoku Solver

Question 1 (Naked Twins)

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

The approach is similar to the 'eliminate' strategy, except that in this case, we are identifying pairs of 2-digit values, and are eliminating those digits from the rest of the 'unit' group (columns, rows, square units, diagonals) Here are the steps that was following to implement this:

1. Identify all the 2-digit values in the given grid

2. Construct a nested for loop with the twin value list to identify if there is a match

3. If yes, loop through each set of unit groups (columns, rows, squares, left-to-right diagonals, and right-to-left diagonals), and check if the matched pair exists in the unit group. 

4. If the pair exists, then remove the digits of the values of matched pair from the rest of the values in the unit group (sanity check: length of the values are checked. This operation is carried out only if the length is more than 1).

5. Iterate the loop for all the unit groups

Question 2 (Diagonal Sudoku)

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

A constraint on diagonals that they should have unique values is similar to the constraint we already have on regular Sudoku on column units, row units and square units.

So, in order to implement this, two sets of diagonals are created: Left-to-right (A1, B2, C3....I9), and Right-to-left (I1, H2, G3,....A9). They are zipped to their respective values to create diagonal dictionaries.

Then, an additional constraint on unit list is made in all the three solve strategies: eliminate, only_choice and naked_twins. The unit list which previously consisted of rows, columns and squares now have diagonals, and the constraint makes sure each unit list consist of unique values.

aind-sudoku's People

Contributors

luisguiserrano avatar clapollo avatar danainschool avatar kkweon avatar

Watchers

James Cloos avatar Kalai Ramea 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.