Sudoku solving technique. Problem Solving Example - The Hardest Sudoku

Sudoku is a very interesting puzzle game. It is necessary to arrange the numbers from 1 to 9 in the field in such a way that each row, column and block of 3 x 3 cells contains all the numbers, and at the same time they should not be repeated. Consider step-by-step instructions on how to play Sudoku, basic methods and a solution strategy.

Solution algorithm: from simple to complex

The algorithm for solving the Sudoku mind game is quite simple: you need to repeat the following steps until the problem is completely solved. Gradually move from the simplest steps to more complex ones, when the first ones no longer allow you to open a cell or exclude a candidate.

Single Candidates

First of all, for a more visual explanation of how to play Sudoku, let's introduce a numbering system for blocks and cells of the field. Both cells and blocks are numbered from top to bottom and from left to right.

Let's start looking at our field. First you need to find single candidates for a place in the cell. They can be hidden or explicit. Consider the possible candidates for the sixth block: we see that only one of the five free cells contains a unique number, therefore, the four can be safely entered in the fourth cell. Considering this block further, we can conclude: the second cell should contain the number 8, since after the exclusion of the four, the eight does not occur anywhere else in the block. With the same justification, we put the number 5.

Carefully review all possible options. Looking at the central cell of the fifth block, we find that there can be no other options besides the number 9 - this is a clear single candidate for this cell. The nine can be crossed out from the rest of the cells of this block, after which the remaining numbers can be easily put down. Using the same method, we pass through the cells of other blocks.

How to discover hidden and explicit "naked couples"

Having entered the necessary numbers in the fourth block, let's return to the empty cells of the sixth block: it is obvious that the number 6 should be in the third cell, and 9 in the ninth.

The concept of "naked pair" is present only in the game of Sudoku. The rules for their detection are as follows: if two cells of the same block, row or column contain an identical pair of candidates (and only this pair!), then the other cells of the group cannot have them. Let's explain this on the example of the eighth block. Putting possible candidates in each cell, we find an obvious "naked pair". The numbers 1 and 3 are present in the second and fifth cells of this block, and there and there there are only 2 candidates each, therefore, they can be safely excluded from the remaining cells.

Completion of the puzzle

If you learned the lesson on how to play Sudoku and followed the above instructions step by step, then you should end up with something like this picture:

Here you can find single candidates: a one in the seventh cell of the ninth block and a two in the fourth cell of the third block. Try to solve the puzzle to the end. Now compare your result with the correct solution.

Happened? Congratulations, this means that you have successfully mastered the lessons on how to play Sudoku and learned how to solve the simplest puzzles. There are many varieties of this game: Sudoku of different sizes, Sudoku with additional areas and additional conditions. The playing field can vary from 4 x 4 to 25 x 25 cells. You may come across a puzzle in which the numbers cannot be repeated in an additional area, for example, diagonally.

Start with simple options and gradually move on to more complex ones, because with training comes experience.

Sudoku solving is a creative process. The rules of the puzzle are very simple, although the logical reasoning during the search for a solution can be of varying degrees of complexity. Experience comes only with time, and each player develops his own strategy. And so that you can better navigate the ways of solving puzzles and get a taste, we present some recommendations.

Start the solution from one.

1. First, "look around" on the playing field, finding all the cells with the number "1".

2. Check successively each of the 3x3 blocks to see if it already contains one. If it does, consider the following.

3. If there is no one in the block yet, try to find all the cells inside this block that could have a one. Don't forget about the rule: each number can appear in each row, each column and each block only once. Exclude from consideration all cells of the block in which the number "1" cannot be located, because the column or row is already "occupied". It is likely that there will be such a block in which there will be only one cell, in which there can be a unit. Enter her.

4. If you are not sure about the uniqueness of the solution, it is better to leave this block and try with another one. A suitable block is sure to be found.

After you "pass" all the blocks with the number "1", repeat the search with a different number. For example with a double. Then three, and so on. Until you check all the numbers from 1 to 9. And you will see that you have already filled in a lot of cells. After that, we advise you to repeat the entire "procedure" again from the very beginning - again from 1 to 9. The second time, things will go easier, because many cells have already been filled. And where you doubted, you can confidently enter a number.

Using the recommendations, it will not be difficult to solve a simple puzzle. We know from experience that people who can easily solve simple Sudokus may have difficulty with complex ones. Therefore, let us consider in detail the solution of one of the problems.

For convenience of explanation, we will use the numbering of rows, columns and 3x3 blocks from 1 to 9. The numbering order is from left to right and from top to bottom.

Designations:

1. The gray block, row or column is the "zone" that we analyze in search of a solution;

2. Highlighted "bold" number (blue) - the desired number found during the analysis;

3. The lines show that the figure from which this line begins cannot be placed in this direction.

We find the number "1" in the 2nd block. The lines coming from the units of the 5th and 8th blocks cross out the rest of the empty cells.

We find the number "1" in the 4th block. For this sleep, we determine where in the 6th block there can be ones by drawing lines from the ones of the 5th and 9th blocks - two ones in the top row. Already from them we draw a line towards the 4th block and a line from the unit of the 5th block.

The search for possible twos was not successful, but you can find a three in the 9th block by drawing lines from threes in the 3rd and 6th blocks. There were no options for the numbers "4", "5", "6", "7". But the number "8" was found in the 8th square: lines from the eights of the 2nd, 5th and 7th blocks. Nine was also missing.

Let's start a new search for units. A unit was found in the first block: the lines from the units in the 2nd and 9th blocks determined the possible positions of the unit in the 3rd block, from which the lines stretched to the 1st block. The remaining lines are visible in the figure. The next unit was found in block 7.

The first two was found in block 4, after which the first five was also determined there. The numbers "3", "4", "6", "7" were not found.

The number "8" of block 1 is determined by the lines from the eights from blocks 4 and 7. Then we find the nine of the 9th row: since it cannot be in blocks 7 and 8 (see lines from the corresponding nines), then it is in the block 9.

The number "9" in the 1st line: it cannot be in block 2, so it is in block 3. In the remaining cell of the line, enter "5". Two digits "9" were found in blocks 5 and 6. We start again with the number "1".

The quarter of the 6th block was found first. Then the four of the 5th column - it cannot be in the 4th and in the 7th row. Three cannot be in the 7th line, so it is in the 4th. Then there is a six in the remaining cell.

In the next step, the queue is optional: first we find the eight, and then the one in block 6, or vice versa.

We continue to arrange the eights: first we find "8" in block 9, and from it we draw a line, defining the eight in block 3.

The next ones were the numbers "1" and "6" in block 3, the order of finding is not fundamental.

Then we will decide on the number "7" in the 9th column: it cannot be in block 6, then it is in the 2nd row. From the five in block 1 we draw a line - we find a place for the number "5" in the 3rd block. In the free cell we enter the last digit - "2".

In the second row we find the number "2", then "4" and finally "9".

Then we find the number "4" in block 8. In the remaining cell - "7". We lead a line from it up to block 5 - a new seven. In the empty cell of the 9th line - "7".

Let's find sequentially the numbers "5", "2", "6" in block 5 and the numbers "7", "3" in the 6th row. Then we get "5" and "6" in the 6th block. The last digit is "6" in the 4th block.

The next "7" and "3" in the 1st block; the numbers "7" and "2" in the 7th column and "5" in block 9. We analyze the 7th row, the 2nd column and place "9" first, then "3" and "2". The final touch is "4" and "6".

Solution completed.

In very complex problems, there is another trick. It is used when it is impossible to calculate a single move in any way. There are at least two cells for one digit in a block (row/column). It is extremely difficult to sort out in your mind all the consequences of a position chosen at random. Then you should enter the number at random, but with a pencil. In this case, the only options can be entered immediately with a ballpoint pen. If after a few moves an error is detected, for example, it is impossible to enter any number in the block - there is no suitable place, then the entire pencil version is erased and the second option is entered in the initial cells. You can also use the entry in the cells of all possible numbers at the moment, this helps to quickly navigate in the search for a solution. In any case, start with easy puzzles and good luck to you!

The Sudoku field is a table of 9x9 cells. A number from 1 to 9 is entered in each cell. The goal of the game is to arrange the numbers in such a way that there are no repetitions in each row, column and each 3x3 block. In other words, each column, row, and block must contain all the numbers from 1 to 9.

To solve the problem, candidates can be written in empty cells. For example, consider a cell in the 2nd column of the 4th row: in the column in which it is located, there are already numbers 7 and 8, in the row - numbers 1, 6, 9 and 4, in the block - 1, 2, 8 and 9 Therefore, we cross out 1, 2, 4, 6, 7, 8, 9 from the candidates in this cell, and we are left with only two possible candidates - 3 and 5.

Similarly, we consider possible candidates for other cells and get the following table:

Candidates are more interesting to deal with and different logical methods can be applied. Next, we will look at some of them.

Loners

The method consists in finding singles in the table, i.e. cells in which only one digit is possible and no other. We write this number in this cell and exclude it from other cells of this row, column and block. For example: in this table there are three "loners" (they are highlighted in yellow).

hidden loners

If there are several candidates in a cell, but one of them is not found in any other cell of a given row (column or block), then such a candidate is called a “hidden loner”. In the following example, candidate "4" in the green block is only found in the center cell. So, in this cell there will definitely be “4”. We enter "4" in this cell and cross it out from other cells of the 2nd column and 5th row. Similarly, in the yellow column, the candidate "2" occurs once, therefore, we enter "2" in this cell and exclude "2" from the cells of the 7th row and the corresponding block.

The previous two methods are the only methods that uniquely determine the contents of a cell. The following methods only allow you to reduce the number of candidates in the cells, which will sooner or later lead to loners or hidden loners.

Locked Candidate

There are times when a candidate within a block is in only one row (or one column). Due to the fact that one of these cells will necessarily contain this candidate, this candidate can be excluded from all other cells of this row (column).

In the example below, the center block contains candidate "2" only in the center column (yellow cells). So one of those two cells must definitely be "2", and no other cells in that row outside of this block can be "2". Therefore, "2" can be excluded as a candidate from other cells in this column (cells in green).

Open Pairs

If two cells in a group (row, column, block) contain an identical pair of candidates and nothing else, then no other cells in this group can have the value of this pair. These 2 candidates can be excluded from other cells in the group. In the example below, candidates "1" and "5" in columns eight and nine form an Open Pair within the block (yellow cells). Therefore, since one of these cells must be "1" and the other must be "5", candidates "1" and "5" are excluded from all other cells of this block (green cells).

The same can be formulated for 3 and 4 candidates, only 3 and 4 cells are already participating, respectively. Open triples: from the green cells, we exclude the values ​​of the yellow cells.

Open fours: from the green cells, we exclude the values ​​of the yellow cells.

hidden couples

If two cells in a group (row, column, block) contain candidates, among which there is an identical pair that does not occur in any other cell of this block, then no other cells of this group can have the value of this pair. Therefore, all other candidates of these two cells can be excluded. In the example below, candidates "7" and "5" in the central column are only in yellow cells, which means that all other candidates from these cells can be excluded.

Similarly, you can look for hidden triples and fours.

x-wing

If a value has only two possible locations in a row (column), then it must be assigned to one of those cells. If there is one more row (column), where the same candidate can also be in only two cells and the columns (rows) of these cells are the same, then no other cell of these columns (rows) can contain this number. Consider an example:

In the 4th and 5th lines, the number "2" can only be in two yellow cells, and these cells are in the same columns. Therefore, the number "2" can be written in only two ways: 1) if "2" is written in the 5th column of the 4th row, then "2" must be excluded from the yellow cells and then in the 5th row the position "2" is uniquely determined by the 7th column.

2) if “2” is written in the 7th column of the 4th row, then “2” must be excluded from the yellow cells and then in the 5th row the position “2” is uniquely determined by the 5th column.

Therefore, the 5th and 7th columns will necessarily have the number "2" either in the 4th row or in the 5th. Then the number "2" can be excluded from other cells of these columns (green cells).

"Swordfish" (Swordfish)

This method is a variation of the .

It follows from the rules of the puzzle that if a candidate is in three rows and only in three columns, then in other rows this candidate in these columns can be excluded.

Algorithm:

  • We are looking for lines in which the candidate occurs no more than three times, but at the same time it belongs to exactly three columns.
  • We exclude the candidate from these three columns from other rows.

The same logic applies in the case of three columns, where the candidate is limited to three rows.

Consider an example. In three lines (3rd, 5th and 7th) candidate "5" occurs no more than three times (cells are highlighted in yellow). However, they belong to only three columns: 3rd, 4th and 7th. According to the “Swordfish” method, candidate “5” can be excluded from other cells of these columns (green cells).

In the example below, the Swordfish method is also applied, but for the case of three columns. We exclude the candidate "1" from the green cells.

"X-wing" and "Swordfish" can be generalized to four rows and four columns. This method will be called "Medusa".

Colors

There are situations when a candidate occurs only twice in a group (in a row, column or block). Then the desired number will definitely be in one of them. The strategy for the Colors method is to view this relationship using two colors, such as yellow and green. In this case, the solution can be in the cells of only one color.

We select all interconnected chains and make a decision:

  • If some unshaded candidate has two differently colored neighbors in a group (row, column, or block), then it can be excluded.
  • If there are two identical colors in a group (row, column or block), then this color is false. A candidate from all cells of this color can be excluded.

In the following example, apply the "Colors" method to cells with candidate "9". We start coloring from the cell in the upper left block (2nd row, 2nd column), paint it yellow. In its block, it has only one neighbor with "9", let's paint it green. She also has only one neighbor in the column, we paint over it in green.

Similarly, we work with the rest of the cells containing the number "9". We get:

Candidate "9" can be either only in all yellow cells, or in all green. In the right middle block, two cells of the same color met, therefore, the green color is incorrect, since this block produces two "9s", which is unacceptable. We exclude, "9" from all green cells.

Another example of the "Colors" method. Let's mark paired cells for the candidate "6".

The cell with "6" in the upper central block (highlighted in lilac) has two multi-colored candidates:

"6" will necessarily be in either a yellow or green cell, therefore, "6" can be excluded from this lilac cell.

A mathematical puzzle called "" comes from Japan. It has become widespread throughout the world due to its fascination. To solve it, you will need to concentrate attention, memory, and use logical thinking.

The puzzle is printed in newspapers and magazines, there are computer versions of the game and mobile applications. The essence and rules in any of them are the same.

How to play

The puzzle is based on the Latin square. The field for the game is made in the form of this particular geometric figure, each side of which consists of 9 cells. The large square is filled with small square blocks, sub-squares, three squares on a side. At the beginning of the game, some of them are already filled with "hint" numbers.

It is necessary to fill in all the remaining empty cells with natural numbers from 1 to 9.

You need to do this so that the numbers do not repeat:

  • in each column
  • in every line,
  • in any of the small squares.

Thus, in each row and each column of the large square there will be numbers from one to ten, any small square will also contain these numbers without repetition.

Difficulty levels

The game has only one correct solution. There are different levels of difficulty: a simple puzzle with a lot of filled cells can be solved in a few minutes. On a complex one, where a small number of numbers are placed, you can spend several hours.

Solution Methods

Various approaches to problem solving are used. Consider the most common.

Exclusion Method

This is a deductive method, it involves the search for unambiguous options - when only one digit is suitable for writing to a cell.

First of all, we take the square most filled with numbers - the lower left. It lacks one, seven, eight and nine. To find out where to put the one, let's look at the columns and rows where this number is: it is in the second column, so our empty cell (the lowest one in the second column) cannot contain it. There are three possible options left. But the bottom line and the second line from the very bottom also contain one - therefore, by the elimination method, we are left with the upper right empty cell in the subsquare under consideration.

Similarly, fill in all empty cells.

Writing Candidate Numbers to a Cell

For the solution, options are written in the upper left corner of the cell - candidate numbers. Then “candidates” that are not suitable according to the rules of the game are crossed out. Thus, all free space is gradually filled.

Experienced players compete with each other in skill, in the speed of filling empty cells, although this puzzle is best solved slowly - and then the successful completion of Sudoku will bring great satisfaction.

All the same, almost everyone can solve this puzzle. The main thing is to choose your level of difficulty on the shoulder. Sudoku is an interesting puzzle game that keeps your sleepy brain and free time busy. In general, anyone who has tried to solve it has already managed to identify some patterns. The more you solve it, the better you begin to understand the principles of the game, but the more you want to somehow improve your way of solving. Since the advent of Sudoku, people have developed many different ways to solve, some easier, some more difficult. Below is a sample set of basic hints and some of the more basic methods for solving Sudoku. First, let's define terminology.

Sophisticated fans can buy a desktop version of Sudoku at ozon.ru

Terminology

Method 1: Singles

Singles (single variants) may be defined by excluding digits already present in rows, columns or areas. The following methods allow you to solve most of the "simple" variants of Sudoku.

1.1 Obvious singles

Since these pairs are both in the third area (upper right), we can also exclude the numbers 1 and 4 from the rest of the cells in this area.

When three cells in one group contain no candidates other than three, those numbers can be excluded from the remaining cells of the group.

Please note: it is not necessary that these three cells contain all the numbers of the trio! It is only necessary that these cells do not contain other candidates.

In this row we have a trio 1,4,6 in cells A, C and G, or two candidates from this trio. These three cells will necessarily contain all three candidates. Therefore, they cannot be elsewhere in this neighborhood, and therefore can be excluded from other cells (E and F).

Similarly, for a quartet, if four cells contain no other candidates than from one quartet, these numbers can be excluded from other cells in this group. As with a trio, cells containing a quartet are not required to contain all four quartet candidates.

3.2 Hidden groups of candidates

For obvious candidate groups (previous method: 3.1), pairs, trios, and quartets allowed candidates to be excluded from other cells in the group.
In this method, hidden candidate groups allow other candidates to be excluded from the cells containing them.

If there are N cells (2,3 or 4) containing N common numbers (and they do not occur in other cells of the group), then the remaining candidates for these cells can be excluded.

In this row, the pair (4,6) occurs only in cells A and C.

The remaining candidates can thus be excluded from these two cells, since they must contain either 4 or 6 and no others.

As with the obvious trios and quartets, the cells do not have to contain all the numbers in the trio or quartet. Hidden trios are very difficult to see. Fortunately, they are not often used to solve Sudoku.
Hidden quartets are almost impossible to see!

Rule 4: Complex methods.

4.1. Connected couples (butterfly)

The following methods are not necessarily more difficult to understand than those described above, but it is not easy to determine when they should be used.

This method can be applied to areas:

As in the previous example, two columns (B and C), where 9 can only be in two cells (B3 and B9, C2 and C8).

Since B3 and C2, as well as B9 and C8, are inside the same area (and not in the same row as in the previous example), 9 can be excluded from the remaining cells of these two areas.

4.2 Complex pairs (fish)

This method is a more complex version of the previous one (4.1 Connected Pairs).

You can apply it when one of the candidates is present in no more than three rows and in all rows they are in the same three columns.