Senin, 18 Juni 2018

Sponsored Links

SUDOKU SOLVER Will Bazil, Ryan Covert, Ricky Parker. - ppt download
src: images.slideplayer.com

The standard sudoku contains 81 cells, in a grid of 9ÃÆ' â € "9, and has 9 squares, each box is the junction of the first 3, middle, or last 3 rows, and the first, middle, or last 3 columns. Each cell can contain numbers from one to nine, and each number can only appear once in each row, column, and box. Sudoku starts with some cells containing numbers ( directions ), and the goal is to complete the remaining cells. The right focus has one solution. Players and researchers can use various computer algorithms to complete Sudokus, learn about their properties, and create new puzzles, including Sudocus with interesting symmetry and other properties.

There are several computer algorithms that will solve most 9ÃÆ' â € "9 puzzles (span> n n increases, creating constraints on the nature of the Sudokus that can be constructed, analyzed, and solved as n increases.


Video Sudoku solving algorithms



Technique

Rewind

Some fans have developed computer programs that will solve Sudoku puzzles using backtracking algorithms, which are a type of violent search. Backtracking is a deep-first search (as opposed to breadth-first search), since it will fully explore one branch to a possible solution before moving to another branch. Although it has been established that about 6.67 x 10 21 the final grid exists, the brute force algorithm can be a practical method for solving Sudoku puzzles.

The brute force algorithm visits the empty cell in some sequence, fills the digits in sequence, or retreats when the number is found invalid. In short, a program will solve the puzzle by placing the digit "1" in the first cell and checking if it is allowed to be there. If there is no violation (check line, column, and box boundaries), then the algorithm will go to the next cell, and put "1" in that cell. When checking the violation, if found that "1" is not allowed, its value is forwarded to "2". If a cell is found where none of the 9 digits is allowed, then the algorithm leaves the cell empty and returns to the previous cell. The value in the cell is then added one. This is repeated until the allowed value in the last cell (81) is found.

Animation shows how Sudoku is accomplished by this method. The puzzle instructions (red numbers) remain fixed while the algorithm tests every unsolved cell with possible solutions. Note that the algorithm can remove all values ​​previously tested if finding an existing device does not meet the Sudoku limit.

The advantages of this method are:

  • The solution is guaranteed (as long as the puzzle is valid).
  • The completion time is largely unrelated to the difficulty level.
  • The algorithm (and therefore the program code) is simpler than any other algorithm, especially compared to the powerful algorithms that ensure the solution to the hardest puzzle.

The disadvantage of this method is that the completion time may be relatively slow compared to the algorithm model after the deductive method. One programmer reports that such an algorithm usually requires at least 15,000 cycles, or as many as 900,000 cycles to complete the Sudoku, each cycle representing a change in the "pointer" position as it travels through the Sudoku cells.

Sudoku can be constructed to work against setbacks. Assuming the solver works from top to bottom (as in animation), a puzzle with some hints (17), no clues in the top row, and having the solution "987654321" for the first row, will work against the algorithm. Thus the program will spend significant time "counting" upward before arriving on the grid that meets the puzzle. In one case, a programmer found a brute force program takes six hours to arrive at a solution for such Sudoku (even though it was a 2008 era computer). Such sudoku can be completed now in less than 30 seconds using a full search routine and faster processor.

Stochastic search/optimization method

Sudoku can be solved by using stochastic (random-based) algorithm. Examples of these methods are:

  1. Specifies a random number to an empty cell in the grid.
  2. Calculate the number of errors.
  3. "Shuffle" numbers are entered until the number of errors is reduced to zero.

The solution to the puzzle was later discovered. The approach to shuffle the numbers includes annealing simulations, genetic algorithms and taboo search. Stochastic-based algorithms are known to be fast, though perhaps not as fast as deductive techniques. However, unlike the latter, the optimization algorithm does not necessarily require problems to be solved logically, thus providing the potential for solving broader problems. Algorithms designed for graph coloring are also known to perform well with Sudokus. It is also possible to express Sudoku as an integer linear programming problem. Such an approach approaches the solution quickly, and then can use branching towards the end. The simplex algorithm is capable of solving improper Sudokus, indicating if Sudoku is invalid (no solution), or providing a set of answers when there is more than one solution.

Programming constraints

Sudoku can also be modeled as a constraint satisfaction problem. In his paper Sudoku as a Constraint Problem , Helmut Simonis describes many reasoning algorithms based on limits that can be applied to model and solve problems. Some constraint solvers include methods for modeling and completing Sudokus, and the program may require fewer than 100 lines of code to complete a simple Sudoku. If the code uses a strong logical reasoning algorithm, incorporating backtracking is only necessary for the most difficult Sudokus. The algorithm that incorporates a constraint-based modeling algorithm with backtracking will have the advantage of a fast completion time, and the ability to complete all of the sudokus.

Right cover

Sudoku puzzles can be described as a proper cover problem. This allows an elegant description of problems and efficient solutions. Sudoku modeling as a proper cover problem and using algorithms such as dancing links will usually solve Sudoku in a few milliseconds.

Maps Sudoku solving algorithms



Develop (search) Sudokus

Computer programs are often used to "search" Sudoku with certain properties, such as a small number of clues, or certain types of symmetry. More than 49,000 Sudokus with 17 clues have been found, but finding a different new one (not a known Sudokus transformation) becomes more difficult as the undiscovered becomes more scarce.

One common method of looking for Sudokus with certain characteristics is called search neighbor . Using this strategy, one or more well known Sudokus that satisfies or almost meets the characteristics being searched is used as a starting point, and the Sudoku is then changed to look for other Sudokus with the property sought. Changes can move one or more hint positions, or remove a small number of instructions, and replace them with a number of different instructions. For example, from a known Sudoku, a search for a new one with fewer clues can be done by deleting two hints and adding one hint in the new location. (This can be called search {-2, 1}). Each new pattern will then be searched in depth for all combinations of hint values, in the hope that one or more results in a valid sudoku (ie solvable and single solution). Methods can also be used to prevent basically equivalent Sudpers for excessive testing.

As a specific example, a 17-sign Sudoku search can start with a known Sudoku 18-mark, and then change it by deleting the three directives , and replacing it with just two directives , in the position different (see the last two pictures). This may find a new Sudokus, but there will be no immediate guarantee that they are fundamentally different from the familiar Sudokus. If looking for a completely new (yet to be discovered) Sudokus, further confirmation will be needed to ensure that each finding is not a transformation of a familiar Sudoku.

loadBoard in C++ Genetic Algorithm Sudoku - YouTube
src: i.ytimg.com


See also

  • Sudoku
  • Sudoku math
  • Sudoku math (minimum number of natural parts)
  • Sudoku Math (Sudoku Automorphic)
  • Combinatorial explosion - (with a summary of the Sudoku grid count compared to the Latin box)
  • Glossary of the Sudoku

Developing a Sudoku solver
src: 3.bp.blogspot.com


References


Sudoku Solver Code in cpp/c++ using Backtracking Algorithm - YouTube
src: i.ytimg.com


External links

  • http://diuf.unifr.ch/pai/people/juillera/Sudoku/Sudoku.html Sudoku Explainer by Nicolas Juillerat (Popular for Sudokus rating in general)
  • http://www2.research.att.com/sw/download/man/man1/sudoku.html sudoku by gsf (Popular to rank the most difficult Sudokus among other things)
  • Pencil-and-Paper Algorithm for Solving Sudoku Puzzles which is also quoted in the popular British newspaper, Daily Mail

Source of the article : Wikipedia

Comments
0 Comments