Thursday, December 28, 2006

Mathematics Of Sudoku

•9 rows, 9 columns, 9 3x3 boxes and 81 cells
•I will refer to rows, columns or boxes as areas
•(p,q) refers to row p and column q
•I number the boxes left to right, top to bottom


How many givens do we need to guarantee a unique solution?

•This is an unknown mathematical problem
•There are examples of uniquely solvable grids with 17 givens


How many givens can we have without guaranteeing a unique solution?

•It is possible to have a puzzle with only four cells blank that is still not uniquely determined



The Number of Sudoku grids

The number of ways of filling in a blank Sudoku grid was shown in May 2005 by Felgenhauer and Jarvis to be 6,670,903,752,021,072,936,960

Saturday, December 23, 2006

History Of Sudoku

The history of Sudoku can be traced back to an 18th century Swiss mathematician by the name of Euler. In 1783, he devised a square 9x9 grid in which all the digits from 1 to 9 appear in every row and column. In other words, in every row and column the digits are never repeated. This is known as a Latin Square. The Latin Square can be described as the forerunner of Sudoku.

Almost 200 years later, a retired American architect named Howard Garns used the concept of the Latin Square and created a puzzle which at that time was given the term Number Place. In 1979, his Number Place puzzles were featured in an American puzzle magazine.
What Howard Garns did was to add another condition to the Latin Square. Not only are the digits from 1 to 9 not repeated in every row and column, they are also not repeated in each of the 9 blocks of 9 cells. But unfortunately Garn's puzzles were only known to the readers of the magazine, and for many years they went unnoticed by the general public.

But everything changed in 1984, when a Japanese puzzle magazine became aware of Number Place, and they took the puzzle to Japan for their readers to enjoy. At first, they gave the puzzle the long name mentioned above. Two years later, Sudoku became a hit in Japan after the Japanese magazine reduced the number of clues, and also arranged the clues symmetrically. These innovations made the puzzle even more challenging and appealing. But although Sudoku became very popular among the people in Japan, for many years it remained relatively unknown outside of that country.

Once again, Sudoku made another journey, this time from Japan to England. That was in 2004. What happened was that a New Zealander by the name of Wayne Gould came across Sudoku puzzles while he was on a trip to Japan. He liked them so much that he spent some time to develop a computer program that could generate Sudoku puzzles automatically. Then armed with an endless supply of Sudoku puzzles from his program, he persuaded The Times of London to carry the puzzles. In November 2004 Sudoku first appeared in an English newspaper, and from then on and within a few months its popularity spread very quickly.

In April last year, Sudoku became a regular feature in a newspaper in New York. This completes Sudoku's westward travel around the world, from 1979 to 2005, starting from America to Japan, and then from Japan to England and back to America. By the end of last year, Sudoku had become a popular pastime all over the world, including Malaysia. Although it took a total of 26 years, Sudoku is a wonderful example of how a good idea will spread in today's world that is so well-connected. But the unfortunate fact behind this story of the global rise of a puzzle is that the creator, Howard Garns, did not live long enough to see his puzzle became a worldwide success. He died in 1989.

Construction of Sudoku Puzzles

Building a Sudoku puzzle can be performed by pre-determining the locations of the givens and assigning them values only as needed to make deductive progress. This technique gives the constructor greater control over the flow of puzzle solving, leading the solver along the same path the compiler used in building the puzzle. Great caution is required, however, as failing to recognize where a number can be logically deduced at any point in construction—regardless of how tortuous that logic may be—can result in an unsolvable puzzle when defining a future given contradicts what has already been built. Building a Sudoku with symmetrical givens is a simple matter of placing the undefined givens in a symmetrical pattern to begin with.

Rating Sudoku Puzzles

The difficulty of a puzzle is based on the relevance and the positioning of the given numbers rather than their quantity. Surprisingly, the number of givens does not always reflect a puzzle's difficulty. Computer solvers can estimate the difficulty for a human to find the solution, based on the complexity of the solving techniques required. Some online versions offer several difficulty levels.

Most publications sort their Sudoku puzzles into four or five rating levels, although the actual cut-off points and the names of the levels themselves can vary widely. Typically, however, the titles are synonyms of "easy", "intermediate", "hard", and "challenging". An easy puzzle can be solved using only scanning; an intermediate puzzle may take markup to solve; a hard or challenging puzzle will usually take analysis.

Another approach is to rely on the experience of a group of human test solvers. Puzzles can be published with a median solving time rather than an algorithmically defined difficulty level.

Computer solutions

There are two general approaches taken in the creation of serious Sudoku-solving programs: human solving methods and rapid-style methods. Human-style solvers will typically operate by maintaining a mark-up matrix, and search for contingencies, matched cells, and other elements that a human solver can utilize in order to determine and exclude cell values.
Many rapid-style solvers employ backtracking searches, with various pruning techniques also being used in order to help reduce the size of the search tree.
Rapid solvers are preferred for trial-and-error puzzle-creation algorithms, which allow for testing large numbers of partial problems for validity in a short time; human-style solvers can be employed by hand-crafting puzzlesmiths for their ability to rate the challenge of a created puzzle and show the actual solving process their target audience can be expected to follow.

Friday, December 22, 2006

Solution methods

Analysis
The two main approaches to analysis are "candidate elimination"and "what-if". In "candidate elimination", progress is made by successively eliminating candidate numerals from cells to leave one choice. After each answer has been achieved, another scan may be performed—usually checking to see the effect of the contingencies. In general, if entering a particular numeral prevents completion of the other necessary placements, then the numeral in question can be eliminated as a candidate. One method works by identifying "matched cell groups". For instance, if precisely two cells within a scope (a particular row, column, or region) contain the same two candidate numerals (p,q), or if precisely three cells within a scope contain the same three candidate numerals (p,q,r), these cells are said to be matched. The placement of those candidate numerals anywhere else within that same scope would make a solution impossible; therefore, those candidate numerals can be deleted from all other cells in the scope.
In the "what-if" approach (also called "guess-and-check", "bifurcation", "backtracking" and "Ariadne's thread"), a cell with two candidate numerals is selected, and a guess is made. The steps are repeated unless a duplication is found or a cell is left without a possible candidate, in which case the alternative candidate must be the solution. For each cell's candidate, the question is posed: 'will entering a particular numeral prevent completion of the other placements of that numeral?' If the answer is 'yes', then that candidate can be eliminated. The what-if approach requires a pencil and eraser or a good layout memory.
There are three kind of conflicts, which can appear during puzzle solving:

  1. basic conflicts - there are only N-1 different candidates in N cell in the area
  2. fish conflicts - when eliminating number from N rows/columns, it will disappear also from N+1 columns/rows.

  3. unique conflicts - this pattern means multiple solutions, all numbers in the pattern exist exactly two times in every area, row and column. If there are only one candidate in the cell, any virtual candidate can be added.

Encountering any of those would indicate that the puzzle is not uniquely solvable. So, if you encounter them as a consequence of "what-if", you use your eraser and go back to try untried alternatives.

Solution methods

Marking up

Scanning stops when no further numerals can be discovered, making it necessary to engage in logical analysis. One method to guide the analysis is to mark candidate numerals in the blank cells. There are two popular notations: subscripts and dots.
In the subscript notation the candidate numerals are written in subscript in the cells. Because puzzles printed in a newspaper are too small to accommodate more than a few subscript digits of normal handwriting, solvers may create a larger copy of the puzzle.
The second notation uses a pattern of dots in each square, where the dot position indicates a number from 1 to 9. The dot notation can be used on the original puzzle. Dexterity is required in placing the dots, since misplaced dots or inadvertent marks inevitably lead to confusion and may not be easily erased.
An alternative technique is to "mark up" the numerals that a cell cannot be. A cell will start empty and as more constraints become known, it will slowly fill until only one mark is missing. Assuming no mistakes are made and the marks can be overwritten with the value of a cell, there is no longer a need for any erasures.





A method for marking likely numerals in a single cell by the placing of pencil dots. To reduce the number of dots used in each cell, the marking would only be done after as many numbers as possible have been added to the puzzle by scanning. Dots are erased as their corresponding numerals are eliminated as candidates.

Solution methods

The strategy for solving a puzzle may be regarded as comprising a combination of three processes:

Scanning


Scanning is performed at the outset and throughout the solution. Scans need to be performed only once in between analyses. Scanning consists of two techniques:
Cross-hatching: the scanning of rows to identify which line in a region may contain a certain numeral by a process of elimination. The process is repeated with the columns. For fastest results, the numerals are scanned in order of their frequency, from high to low. It is important to perform this process systematically, checking all of the digits 1–9.
Counting 1–9 in regions, rows, and columns to identify missing numerals. Counting based upon the last numeral discovered may speed up the search. It also can be the case, particularly in tougher puzzles, that the best way to ascertain the value of a cell is to count in reverse—that is, by scanning the cell's region, row, and column for values it cannot be, in order to see what remains.
Advanced solvers look for "contingencies" while scanning, narrowing a numeral's location within a row, column, or region to two or three cells. When those cells lie within the same row and region, they can be used for elimination during cross-hatching and counting. Puzzles solved by scanning alone without requiring the detection of contingencies are classified as "easy"; more difficult puzzles cannot be solved by basic scanning alone. scanning, marking up, and analyzing.





The top right region must contain a 5. By hatching across and up from 5s elsewhere, the solver can eliminate all the empty cells in the region which cannot contain a 5. This leaves only one possibility (shaded green).


Go To : Sudoku solving techniques

Sudoku


Sudoku puzzles are addictive brain teasers that have been referred to as wordless crossword puzzles. They can be solved by lateral thinking alone and have been making quite an impact around the world.

Sudoku, also known as Number Place or Nanpure, is a logic-based placement puzzle. The objective is to fill the grid so that every column, every row and every 3×3 box contains the digits 1 to 9. The puzzle setter provides a partially completed grid so that there is only one solution.

Completed Sudoku puzzles are a type of Latin square, with an additional constraint on the contents of individual regions. Leonhard Euler is sometimes (incorrectly) cited as the source of the puzzle, based on his work with Latin squares.

The modern puzzle was invented by an American, Howard Garns, in 1979 and published by Dell Magazines under the name "Number Place". It became popular in Japan in 1986, when it was published by Nikoli and given the name Sudoku. It became an international hit in 2005.

The name "Sudoku" is the Japanese abbreviation of a longer phrase, "Sūji wa dokushin ni kagiru",meaning "the digits must occur only once". It is a trademark of puzzle publisher Nikoli Co. Ltd. in Japan. Other Japanese publishers refer to the puzzle as Number Place, the original U.S. title, or as "Nanpure" for short. Some non-Japanese publishers spell the title as "Su Doku".

The attraction of the puzzle is that the rules are simple, yet the line of reasoning required to solve the puzzle may be complex. The level of difficulty can be selected to suit the audience.


Go To : Sudoku solving techniques