Code Monkey home page Code Monkey logo

depth-first_sudoku_solver's Introduction

Depth-First Sudoku Solver

Andrew Daws
CS 455-01
April 30, 2014

Description

For centuries Sudoku puzzles have created and attempted to be solved through simple brainstorming. For anyone who is unaware of Sudoku, it is a system of logic heavy, combinatorial number-placement puzzles in which the objective is to fill a 9x9 grid such that each of the nine 3x3 sub-grids, rows, and columns are composed of all digits from 1 to 9 so there are no duplicates. Any generated Sudoku puzzle is composed of a partially filled grid, from which a player is to try and fill the whole puzzle to completion, such that the unique solution is found. As any Sudoku players will tell you, puzzles can vary greatly in complexity, creating wide ranges of completion times. This presents the idea that the optimal method to solve Sudoku puzzles is to instead use the great power of computing which should finish puzzles considerably faster. Unfortunately the problem is still not nullified unless a suitable solving method is established and used, which can require sophisticated strategies with the massive number of possible routes that can be taken at any point, creating an unimaginable number of potential solutions.

Purpose:

The purpose of this project is to write a program that will make use of some artificial intelligence technique to solve a given problem. Thus through the completion of this project at least one problem solving method will be understood, such that it can be implemented elsewhere.

Approach

One route that can be taken is to search for the solution through one of multiple possible methods. There are several search algorithms that can be used such as Breadth-First Search (BFS) and greedy search, but in the case of Sudoku the optimal algorithm is Depth-First Search (DFS).

Depth-First Search involves the algorithm recursively traversing a search tree or graph structure as far as possible along a particular branch before backtracking to a previous untraveled option if it had not reached the target goal along a branch. Thus in the case of Sudoku the DFS algorithm will recursively consider all possible valid values for a square with the currently known valid grid before changing to a new square.
This allows the algorithm to simplify the search tree each iteration due to the decreasing number of potential values in each square as it further completes any particular set of rows, columns, or 3x3 sub-grids. The algorithm will finish successfully upon finding the correct value for each square that results in the unique solution in which all rows, columns, and 3x3 sub-grids are composed of all values from 1 to 9.

Included Files:

  • README.md
  • SodokuSolver.py
  • Puzzles folder with puzzle text files [1-25]

Instructions:

  1. Launch SodokuSolver.py
  2. The program will ask to select a puzzle number, each number corresponding to the given number text file in the Puzzles folder
  3. If a valid puzzle is selected, the program will attempt to solve the given puzzle
  4. Upon completion the program will ask to continue and solve another puzzle

depth-first_sudoku_solver's People

Contributors

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