Algorithm for solving complex Sudoku. Sudoku game rules for beginners

How to play Sudoku?


Sudoku is a very popular number puzzle. Once you understand how to play Sudoku, you won’t be able to put it down!

The essence of the game:

The cells of the playing field must be filled with numbers from 1 to 9. There should not be repeated numbers in each vertical and horizontal line. Also, they cannot be repeated in small squares (3x3 cells). At the very beginning of the game there are already numbers (depending on the difficulty of the level, the number of initially given numbers may differ).

Rules for playing Sudoku:

  • Select a row, column or square with the maximum number given numbers. Fill in what is missing (it is better to use a pencil). In almost all cases, there is a place where only 1 number fits.
  • Next, look through each column in turn, compare which numbers can fit into each cell. You can write down options on a separate piece of paper.
  • When also looking at lines and squares, eliminate numbers that are repeated.
  • As you fill the puzzle with numbers, it will become easier to solve.

Start playing Sudoku with easy tasks, because the ability to solve the puzzle comes with experience. Or play Sudoku online - incorrect numbers will be highlighted in a different color. This will help you get used to the game. During this lesson, logic develops, so you can gradually complicate the level. Also watch the video attached to the article.

  • Tutorial

1. Basics

Most of us hackers know what Sudoku is. I won’t talk about the rules, but will go straight to the methods.
To solve a puzzle, no matter how complex or simple, the cells that are obvious to fill are initially looked for.


1.1 "The Last Hero"

Let's look at the seventh square. There are only four free cells, which means something can be filled quickly.
"8 " on D3 blocks filling H3 And J3; similar " 8 " on G5 closes G1 And G2
With a clear conscience we put " 8 " on H1

1.2 "The Last Hero" in line

After looking at the squares for obvious solutions, we move on to the columns and rows.
Let's consider " 4 " on the field. It is clear that it will be somewhere in the line A .
We have " 4 " on G3 what's yawning A3, There is " 4 " on F7, cleaning A7. And another one " 4 " in the second square prohibits its repetition for A4 And A6.
"The Last Hero" for our " 4 " This A2

1.3 "No choice"

Sometimes there are multiple reasons for a particular location. " 4 " V J8 would be a great example.
Blue the arrows indicate that this is the last possible number in the square. Reds And blue the arrows give us the last number in the column 8 . Greens arrows give the last possible number in the line J.
As you can see, we have no choice but to put this " 4 "in place.

1.4 “Who else if not me?”

It is easier to fill in the numbers using the methods described above. However, checking the number as the last possible value also gives results. The method should be used when it seems that all the numbers are there, but something is missing.
"5 " V B1 is placed based on the fact that all numbers are from " 1 " before " 9 ", except " 5 " is in row, column and square (marked in green).

In the jargon it's " Naked loner". If you fill the field with possible values ​​(candidates), then in the cell such a number will be the only possible one. By developing this technique, you can search for " Hidden singles" - numbers unique to a specific row, column or square.

2. "The Naked Mile"

2.1 "Naked" couples
""Naked" couple" - a set of two candidates located in two cells belonging to one common block: row, column, square.
It is clear that the correct solutions to the puzzle will only be in these cells and only with these values, while all other candidates from common block may be removed.


There are several "naked couples" in this example.
Red in line A cells highlighted A2 And A3, both containing " 1 " And " 6 "I don't know yet exactly how they are located here, but I can easily remove all the others." 1 " And " 6 " from line A(marked in yellow). Also A2 And A3 belong common square, so we remove " 1 " from C1.


2.2 "Threesome"
"Naked Threes"- a complicated version of “naked couples”.
Any group of three cells in one block containing All in all three candidates is "naked threesome". When such a group is found, these three candidates can be removed from other cells in the block.

Combinations of candidates for "naked three" could be like this:

// three numbers in three cells.
// any combinations.
// any combinations.

In this example everything is pretty obvious. In the fifth square of the cell E4, E5, E6 contain [ 5,8,9 ], [5,8 ], [5,9 ] respectively. It turns out that in general these three cells have [ 5,8,9 ], and only these numbers can be there. This allows us to remove them from other block candidates. This trick gives us a solution" 3 " for cell E7.

2.3 "The Fab Four"
"The Naked Four" a very rare phenomenon, especially in its complete form, and yet gives results when detected. The logic of the solution is the same as in "naked threes".

In the above example, in the first square of the cell A1, B1, B2 And C1 generally contain [ 1,5,6,8 ], so these numbers will only occupy these cells and no others. We remove candidates highlighted in yellow.

3. “Everything secret becomes clear”

3.1 Hidden pairs
A great way to expand the field is to search hidden pairs. This method allows you to remove unnecessary candidates from the cell and allow the development of more interesting strategies.

In this puzzle we see that 6 And 7 is in the first and second squares. Besides 6 And 7 is in the column 7 . Combining these conditions, we can state that in cells A8 And A9 There will be only these values ​​and we will remove all other candidates.


A more interesting and complex example hidden pairs. The pair [ 2,4 ] V D3 And E3, cleaning 3 , 5 , 6 , 7 from these cells. Highlighted in red are two hidden pairs consisting of [ 3,7 ]. On the one hand, they are unique for two cells in 7 column, on the other hand - for the row E. Candidates highlighted in yellow are removed.

3.1 Hidden triplets
We can develop hidden couples before hidden triplets or even hidden fours. Hidden threesome consists of three pairs of numbers located in one block. Such as, and. However, as is the case with "naked threesomes", each of the three cells does not have to contain three numbers. Will work Total three numbers in three cells. For example , , . Hidden Threes will be masked by other candidates in the cells, so you first need to make sure that troika applicable to a specific block.


In that complex example there are two hidden threesomes. The first one, marked in red, in the column A. Cell A4 contains [ 2,5,6 ], A7 - [2,6 ] and cell A9 -[2,5 ]. These three cells are the only ones that can contain 2, 5 or 6, so those are the only ones that will be there. Therefore, we remove unnecessary candidates.

Second, in the column 9 . [4,7,8 ] are unique to cells B9, C9 And F9. Using the same logic, we remove candidates.

3.1 Hidden fours

Great example hidden fours. [1,4,6,9 ] in the fifth square can only be in four cells D4, D6, F4, F6. Following our logic, we remove all other candidates (marked in yellow).

4. “Non-rubber”

If any of the numbers appears twice or thrice in the same block (row, column, square), then we can remove that number from the conjugate block. There are four types of pairing:

  1. Pair or Three squared - if they are located on one line, then you can remove all other similar values ​​​​from the corresponding line.
  2. Pair or Three in a square - if they are located in one column, then you can remove all other similar values ​​​​from the corresponding column.
  3. Pair or Three in a row - if they are located in one square, then you can remove all other similar values ​​​​from the corresponding square.
  4. Pair or Three in a column - if they are located in one square, then you can remove all other similar values ​​​​from the corresponding square.
4.1 Pointing pairs, triplets

Let me show you this puzzle as an example. In the third square" 3 "is only in B7 And B9. Following the statement №1 , we remove candidates from B1, B2, B3. Likewise, " 2 " from the eighth square removes a possible value from G2.


A special puzzle. Very difficult to solve, but if you look closely, you can notice several pointing pairs. It is clear that it is not always necessary to find them all in order to advance in the solution, but each such find makes our task easier.

4.2 Reducing the irreducible

This strategy involves carefully analyzing and comparing rows and columns with the contents of the squares (rules №3 , №4 ).
Consider the line A. "2 "are possible only in A4 And A5. Following the rule №3 , remove " 2 " their B5, C4, C5.


Let's continue solving the puzzle. We have a single location " 4 " within one square in 8 column. According to the rule №4 , we remove unnecessary candidates and, in addition, get a solution" 2 " For C7.

Sudoku is a very interesting puzzle. It is necessary to arrange the numbers from 1 to 9 in the field so 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. Let's consider step by step instructions, how to play Sudoku, basic methods and strategy for solving.

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 complete solution tasks. Gradually move from the most simple steps to more complex ones, when the first ones no longer allow opening a cell or eliminating a candidate.

Single candidates

First of all, for a more clear explanation of how to play Sudoku, we will introduce a system for numbering blocks and cells of the field. Both cells and blocks are numbered from top to bottom and 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 obvious. Let's consider possible candidates for the sixth block: we see that only one of the five free cells contains unique number, therefore, the four can be safely entered into the fourth cell. Considering this block further, we can conclude: the second cell must contain the number 8, since after eliminating the four, the eight does not appear anywhere else in the block. With the same justification we put the number 5.

Review everything carefully possible options. Looking at the central cell of the fifth block, we find that besides the number 9 there cannot be any more options - this is a clear single candidate for this cell. Nine can be crossed out from the remaining cells of this block, after which the remaining numbers can be easily entered. Using the same method, we go through the cells of other blocks.

How to detect hidden and obvious “naked pairs”

Having entered the necessary numbers in the fourth block, we return to the unfilled 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 couple" is present only in the game 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 remaining cells of the group cannot have them. Let's explain this using the eighth block as an example. Having placed possible candidates in each cell, we find a clear “naked pair”. The numbers 1 and 3 are present in the second and fifth cells of this block, and there are only 2 candidates in both, therefore, they can be safely excluded from the remaining cells.

Completing the puzzle

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

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 the result with the correct solution.

Happened? Congratulations, because this means that you have successfully learned the lessons of how to play Sudoku and learned how to solve simple puzzles. There are many varieties of this game: Sudoku 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.

I would like to say that Sudoku is a really interesting and exciting task, a riddle, a puzzle, a puzzle, a digital crossword, you can call it whatever you like. The solution of which will not only bring real pleasure to thinking people, but will also allow in the process exciting game develop and train logical thinking, memory, perseverance.

For those who are already familiar with the game in any of its manifestations, the rules are known and understandable. And for those who are just thinking about starting, our information may be useful.

The rules for playing Sudoku are not complicated; they are found on the pages of newspapers or can be found quite easily on the Internet.

The main points are laid out in two lines: the main task of the player is to fill all the cells with numbers from 1 to 9. This must be done in such a way that in a row, column and mini-square 3x3, none of the numbers are repeated twice.

Today we offer you several electronic game options, including more than a million built-in puzzle options in each game player.

For clarity and a better understanding of the process of solving the riddle, let's consider one of the simple options, the first difficulty level of Sudoku-4tune, 6** series.

And so, a playing field is given, consisting of 81 cells, which in turn make up: 9 rows, 9 columns and 9 mini-squares measuring 3x3 cells. (Fig.1.)

Do not be confused by the further mention of an electronic game. You can find the game on the pages of newspapers or magazines, the basic principle remains the same.

The electronic version of the game provides great opportunities to choose the difficulty level of the puzzle, options for the puzzle itself and their number, at the request of the player, depending on his preparation.

When you turn on the electronic toy, key numbers will be given in the cells of the playing field. Which cannot be transferred or changed. You can choose the option that is more suitable for the solution, in your opinion. Reasoning logically, starting from the given numbers, it is necessary to gradually fill the entire playing field with numbers from 1 to 9.

An example of the initial arrangement of numbers is shown in Fig. 2. Key numbers, as a rule, in the electronic version of the game are marked with an underscore or a dot in the cell. In order not to confuse them in the future with the numbers that will be set by you.


Looking at the playing field. It is necessary to decide where to start the solution. Typically, you need to determine the row, column, or mini square that has the minimum number of empty cells. In the version we have presented, we can immediately select two lines, top and bottom. These lines are missing just one digit. Thus, a simple decision is made, having determined the missing numbers -7 for the first line and 4 for the last, we enter them into the free cells of Fig. 3.


The resulting result: two completed lines with numbers from 1 to 9 without repetitions.

Next move. Column number 5 (from left to right) has only two free cells. After some thought, we determine the missing numbers - 5 and 8.

To achieve a successful result in the game, you need to understand that you need to navigate in three main directions: column, row and mini-square.

In this example, it is difficult to navigate only by rows or columns, but if you pay attention to the mini-squares, it becomes clear. It is impossible to enter the number 8 in the second (from the top) cell of the column in question, otherwise there will be two eights in the second mine-square. Likewise with the number 5 for the second cell (bottom) and the second lower mini-square in Fig. 4 (wrong location).


Although the solution seems correct for a column, nine digits, in a column, without repetition, it contradicts the basic rules. In mini-squares, numbers should also not be repeated.

Accordingly, for the correct solution, you need to enter 5 in the second (top) cell, and 8 in the second (bottom) cell. This decision fully complies with the rules. For the correct option, see Figure 5.

Further solution to a seemingly simple problem requires careful consideration of the playing field and connection logical thinking. You can again use the principle of the minimum number of free cells and pay attention to the third and seventh columns (from left to right). There were three cells left unfilled. Having counted the missing numbers, we determine their values ​​- these are 2,3 and 9 for the third column and 1,3 and 6 for the seventh. Let's leave filling out the third column for now, since there is no certain clarity with it, unlike the seventh. In the seventh column you can immediately determine the location of the number 6 - this is the second free cell from the bottom. What is this conclusion based on?

When examining the mini-square, which includes the second cell, it becomes clear that it already contains the numbers 1 and 3. Of the digital combinations 1,3 and 6 we need, there is no other alternative. Filling the remaining two free cells of the seventh column is also not difficult. Since the third row already contains a filled 1, 3 is entered into the third cell from the top of the seventh column, and 1 is entered into the only remaining free second cell. For an example, see Figure 6.


Let's leave the third column for now for a clearer understanding of the moment. Although, if you wish, you can make a note for yourself and enter the expected version of the numbers required for installation in these cells, which can be corrected if the situation becomes clearer. Electronic games Sudoku-4tune, 6** series allow you to enter more than one number in the cells for a reminder.

Having analyzed the situation, we turn to the ninth (lower right) mini-square, in which, after our decision, there were three free cells left.

Having analyzed the situation, you can notice (an example of filling a mini-square) that the following numbers 2.5 and 8 are missing to completely fill it. Having examined the middle, free cell, you can see that of the necessary numbers only 5 fits here. Since 2 is present in the top cell column, and 8 in a row, which, in addition to the mini-square, includes this cell. Accordingly, in the middle cell of the last mini-square we enter the number 2 (it is not included in either the row or the column), and in the top cell of this square we enter 8. Thus, we have the lower right (9th) mini-square completely filled. a square with numbers from 1 to 9, while the numbers are not repeated in columns or rows, Fig. 7.


As free cells are filled, their number decreases, and we are gradually getting closer to solving our puzzle. But at the same time, solving a problem can be both simplified and complicated. And the first method of filling the minimum number of cells in rows, columns or mini-squares ceases to be effective. Because the number of explicitly defined digits in a particular row, column, or mini-square decreases. (Example: the third column we left). In this case, you need to use the method of searching for individual cells, setting numbers that do not raise any doubts.

In electronic games Sudoku-4tune, 6** series, it is possible to use a hint. Four times per game you can use this function and the computer itself will set the correct number in the cell you have chosen. In the 8** series models there is no such function, and the use of the second method becomes the most relevant.

Let's look at the second method in the example we're using.

For clarity, let's take the fourth column. The empty number of cells in it is quite large, six. Having calculated the missing numbers, we determine them - these are 1,4,6,7,8 and 9. You can reduce the number of options by taking as a basis the average mini-square, which has a fairly large number of specific numbers and only two free cells in a given column. Comparing them with the numbers we need, we can see that 1,6, and 4 can be excluded. They should not be in this mini-square to avoid repetition. That leaves 7,8 and 9. Please note that in the row (fourth from the top), which includes the cell we need, there are already numbers 7 and 8 from the three remaining ones that we need. Thus, the only option left for this cell is number 9, Fig. 8 Doubts about the correctness this option The fact that all the figures we considered and excluded were originally given in the assignment does not cause a decision. That is, they are not subject to any change or transfer, confirming the uniqueness of the number we have chosen for installation in this particular cell.


Using two methods simultaneously depending on the situation, analyzing and thinking logically, you will fill in all the empty cells and come to the correct solution to any Sudoku puzzle, and this riddle in particular. Try to complete the solution to our example in Fig. 9 yourself and compare it with the final answer shown in Fig. 10.


Perhaps you will determine for yourself any additional key points in solving puzzles, and develop your own system. Or take our advice, and it will be useful for you, and will allow you to join a large number lovers and fans of this game. Good luck.

When solving Sudoku, be consistent in your reasoning. Check your actions periodically, because if you make a mistake at the beginning of the solution, it may ultimately lead to an incorrect solution to the entire puzzle. It is easier to avoid mistakes at the beginning of a solution than when a contradiction is discovered in the solved puzzle.

The following methods for solving Sudoku are presented in order of their difficulty and frequency of use in practice.

Selection of candidates

This technique is used to begin solving any Sudoku, regardless of its complexity. In accordance with the proposed task, in the empty cells it is necessary to enter variants of numbers that can be determined by excluding numbers already present in rows, columns or blocks.

For example, consider cell A2, it is marked gray. “1” – available in the block, “2” – available in the row, “3” – available in the block and row, “4” – available in the row, “5” – available in the column, “7” – available in the block, "8" is in the row, "9" is in the column. Accordingly, the only option for this cell is the number “6”.

But in most cases, there are several candidates for each cell. Let's fill the grid with all possible candidates for each cell.

As you can see, there are only two cells in which there is only one candidate - A2 and D9, they are called the only candidates. After finding the only candidates, it is also necessary to cross them out from the candidates in other cells (cells of this column, row, block). So, by deleting the number “6” from line 2, column A and block 1, we also get the only candidate in cell B1 – the number “2”. We will continue to do so in the same way.

However, there are also “hidden” single candidates. For example, let's take cell I7. This cell is located in block 9. In this block, the number 5 can only be in cell I7, since columns G and H already have the number 5, and it is also present in line 8. Accordingly, of the three candidates for cell I7, we leave only the number “5”.

Elimination of candidates

The methods described above allow you to unambiguously determine which number needs to be entered in a particular cell, the following will allow you to reduce their number, which will ultimately lead to only one candidate.

During the solution process, a situation may arise where a certain number in a block can only be located in one row or column within that block. As a consequence, this number cannot appear in other cells in that row or column outside the block.

Let's consider block 5. In this block, the number "4" can only be in cells D5 and F5, i.e. in line 5. Accordingly, no matter which of these two cells the number “4” is in, it cannot be in line 5 in other blocks, so it can be safely crossed out from the candidate cells G5.

There is also the opposite option to the previous method. If a certain number in a row or column can only be located within one block, then the same number cannot be located in other cells of the block in question.

So in line 1 the number “4” can only be in cells D1 and F1, i.e. in block 2. Therefore, no matter which of these two cells the number “4” is in, it can no longer be in block 2 in other cells, so it can be safely crossed out from the candidate cells D3 and F3.

If two cells in a block, row, or column contain only a pair of identical candidates, then these candidates cannot be in other cells in that block, row, or column.

Cells G9 and H9 contain the candidate pair "6" and "8". Accordingly, no matter which of these two cells contains the numbers “6” and “8” (if “6” is in G9, then “8” is in H9, and vice versa), they cannot be in block 9 in other cells, the same as in line 9. Therefore, they can be safely deleted from the candidate cells H7, G8, B9, C9, F9.

This method can also be used for three and four candidates; only cells in a block, row, column must be taken three and four, respectively.

From cells isolated yellow, – B7, E7, H7 and I7 we cross out the candidates contained in the cells highlighted in gray – A7, D7 and F7.

We do the same with fours. From the cells highlighted in yellow, C1 and C6, we cross out the candidates contained in the cells highlighted in gray, C4, C5, C8 and C9.

But there are often “hidden” pairs of candidates. If in two cells in a block, row or column, among the candidates there is a pair of candidates that is not found in any other cell of the block, row or column, then no other cells in the block, row or column can contain candidates from this pair. Therefore, all other candidates from these two cells can be crossed out.

For example, in column G, the pair of numbers “7” and “9” occurs only in cells G1 and G2. Therefore, all other candidates from these cells can be removed.

You can also look for “hidden” threes and fours.

There are more complex ways, used in solving Sudoku. They are not so much difficult to understand as when to apply them. So, for example, if in one of the columns a candidate can only be in two cells, and at the same time there is a column in which the same candidate can also be in only two cells, and all these four cells form a rectangle, then this candidate can be excluded from other cells of these lines.

By analogy, from two rows, excluded candidates will then be in columns.

In column A, the number “2” can only appear in two cells A4 and A6, and in column E in E4 and E6. Accordingly, these pairs of cells are in the same rows - 4 and 6, forming a rectangle.

A certain dependence has formed:

If the number “2” is in cell A4, then it will also be in cell E6 (it cannot be in cell E4, because the number “2” will already be in line 4, and it will not be in cell A6 either, i.e. because the number “2” will already be in column A and block 4);

If the number “2” is in cell A6, then it will also be in cell E4 (it cannot be in cell E6, because the number “2” will already be in line 6, and it will not be in cell A4 either, i.e. because the number “2” will already be in column E and block 5).

Therefore, wherever the number “2” is located, in cells A4 and E6 or A6 and E4, you can safely cross out the number “2” from other cells on lines 4 and 6. In addition, this method can be applied to blocks. Since in block 4 the number “2” will definitely be in cells A4 or A6, it can also be crossed out from the candidate cells of block 4.

These are the main ways in which you can solve classic Sudoku. If Sudoku is not difficult, then it can be solved using the first methods. Solving more difficult puzzles You can’t do without the latest methods. But these methods are not formulaic; in the process of guessing, you will develop your own tactics and strategy. The more you solve Sudoku, the better you will get at it. And you won’t have to write down all the candidates, and you can easily keep them “in your head.”

An example of solving a classic Sudoku

Now let’s try to solve the following Sudoku in its entirety.

First, let's write down all the candidates.

Now let's identify the only candidates (gray cells). And cross them out from the candidates for other cells in blocks, rows, columns (yellow cells).

At the same time, in some cells we again have the only candidates (for example, in line 1, the number “2” is only in cell B1), we also cross them out from the candidates in other cells of blocks, rows, columns.

Now let’s find the “hidden” single candidates (gray cells). And cross them out from candidates for other cells in blocks, drains, columns (yellow cells).

At the same time, in some cells we again have “hidden” unique candidates (for example, in line 1, the number “5” is only in cell C1), we also cross them out from the candidates in other cells of blocks, rows, columns.

Now take cell H5. In line 5, the number "2" appears only in this cell. We continue to solve our Sudoku regarding this cell.

After only the only candidates remain in some cells, we cross them out from other cells in rows, columns and blocks.

As a result, we get the following combination.

Having solved it, we come to the only correct solution:

This is one of the options for solving this Sudoku. Of course, it was possible to start the solution from other cells and in other ways, but this solution shows that Sudoku has only one correct solution and you can find it logically, and not by searching numbers.

Share