0% found this document useful (1 vote)
246 views

An Exhaustive Study On Different Sudoku Solving Techniques: Keywords

How to solve sudoku, complete guide

Uploaded by

Ravi Shankar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
246 views

An Exhaustive Study On Different Sudoku Solving Techniques: Keywords

How to solve sudoku, complete guide

Uploaded by

Ravi Shankar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

IJCSI International Journal of Computer Science Issues, Vol.

11, Issue 2, No 1, March 2014


ISSN (Print): 1694-0814 | ISSN (Online): 1694-0784
www.IJCSI.org 247

An Exhaustive Study on different Sudoku Solving


Techniques
Arnab Kumar Maji1, Sunanda Jana2, Sudipta Roy3, and Rajat Kumar Pal4

1
Department of Information Technology, North Eastern Hill University, Shillong, Meghalaya 793 022, India

2
Department of Computer Science and Engineering ,Haldia Institute of Technology, Haldia, West Bengal 721 657, India

3
Department of Information Technology, Assam University, Silchar, Assam 788 011, India

4
Department of Computer Science and Engineering,University of Calcutta, Kolkata, West Bengal 700 009, India

Abstract
‘Sudoku’ is the Japanese abbreviation of a longer phrase, ‘Suuji wa integer. But incidentally when the value of n is bounded by
dokushin ni kagiru’, meaning ‘the digits must remain single’. It is a some constant, solutions may be obtained in reasonable
very popular puzzle that trains our logical mind. There are several amount of time [2, 3].
approaches to solve this well-liked puzzle. In any case, the problem
of solving a given Sudoku puzzle finds numerous applications in TABLE I. Number of clues given in a Sudoku puzzle in defining the level of
practice. In this paper, an exhaustive study has been made on difficulty of a Sudoku instance.
different techniques for solving a Sudoku puzzle.
Difficulty Level Number of Clues
Keywords: Sudoku puzzle, Cell, Minigrid, Elimination,
Backtracking. 1 (Extremely Easy) More than 46

2 (Easy) 36-46
1. Introduction
3 (Medium) 32-35
A Sudoku is usually a 9×9 grid based puzzle problem which
is subdivided into nine 3×3 minigrids, wherein some clues 4 (Difficult) 28-31
are given and the objective is to fill it up for the remaining
blank positions. Furthermore, the objective of this problem is 5 (Evil) 17-27
to compute a solution where the numbers 1 through 9 will
occur exactly once in each row, exactly once in each column, TABLE II. The lower bound on the number of clues given in each row and
column of a Sudoku instance for each corresponding level of difficulty.
and exactly once in each minigrid independently obeying the
given clues. One such problem instance is shown in Figure Lower Bound on the
1(a) and its solution is shown in Figure 1(b). Difficulty Level Number of Clues in Each
Row and Column
5 8 7 2 6 5 1 4 9 3 8 7

1 4 9 1 4 8 3 7 5 6 9 2 1 (Extremely Easy) 05
6 4 7 9 3 2 6 8 5 1 4
2 (Easy) 04
4 5 2 3 6 8 4 5 1 2 9 7 3

3 7 1 8 9 6 4 2 5 3 (Medium) 03
9 7 4 1 8 9 5 2 7 3 4 1 6 8

8 5 8 2 6 9 5 3 7 4 1
4 (Difficult) 02
1 3 6 5 1 9 4 8 7 2 3 6
5 (Evil) 00
4 3 1 8 4 3 7 6 2 1 8 5 9

There are quite a few logic techniques that researchers use to


Figure 1. (a) An instance of the Sudoku problem. (b) A solution of this solve this problem. Some are basic simple logic, some are
Sudoku instance (shown in Figure 1(a)).
more advanced. Depending on the difficulty of the puzzle, a
Solving an instance of Sudoku problem is NP-complete [4]. blend of techniques may be needed in order to solve a
So it is unlikely to develop a deterministic polynomial time puzzle. In fact, most computer generated Sudoku puzzles
algorithm for solving a Sudoku instance of size n×n, where n rank the difficulty based upon the number of empty cells in
is any large number such that the square root of n is an the puzzle and how much effort is needed to solve each of

Copyright (c) 2014 International Journal of Computer Science Issues. All Rights Reserved.
IJCSI International Journal of Computer Science Issues, Vol. 11, Issue 2, No 1, March 2014
ISSN (Print): 1694-0814 | ISSN (Online): 1694-0784
www.IJCSI.org 248

them. Table I shows a comparison chart of the number of column, and minigrid). When it encounters a conflict (which
clues for different difficulty levels [3]. can happen very quickly), it erases the 1 just placed and
However, position of each of the empty cells also affects the inserts 2 or, if that is invalid, 3 or the next legal number.
level of difficulty. If two puzzles have the same number of After placing the first legal number possible, it moves to the
clues at the beginning of a Sudoku game, the puzzle with the next cell and starts again with a 1 (or a minimum possible
givens (or clues) in clusters is graded in higher level than acceptable value). If the number that has to be altered is a 9,
that with the givens scattered over the space. Based on the which cannot be raised by one in a standard 99 Sudoku
row and column constraints, the lower bound on the number grid, the process backtracks and increases the number in the
of clues are regulated in each row and column for each previous cell (or the next to the last number placed) by one.
difficulty level [3] as shown in Table II. Then it moves forward until it hits a new conflict.
In this paper, an attempt has been made to make an In this way, the process may sometimes backtrack several
exhaustive study on the basic backtracking approach and times before advancing. It is guaranteed to find a solution if
other elimination based approaches for solving Sudoku there is one, simply because it eventually tries every possible
puzzle. number in every possible location. This algorithm is very
effective for size two puzzles. Unfortunately, for size three
2.Study on different Sudoku Solving puzzles, there are nine possibilities for each cell. This means
Techniques that there are roughly 981−n possible states that might need to
A 9×9 Sudoku puzzle can be divided into nine 3×3 be searched, where n×n is the size of a given puzzle.
minigrids. We have labelled each minigrid from 1 to 9, with Obviously this version of backtracking search does not work
minigrid 1 at the top-left corner and minigrid 9 at the for size 3 puzzles. Fortunately, there are several means by
bottom-right corner; minigrid numbers are shown in faded which this algorithm can be improved: constraint
larger font size in Figure 2. Also we refer to each cell in the propagation, forward checking, and choosing most
grid by its row number followed by its column number, as constrained value first [2] are some of them.
shown in the same figure. Some other techniques include elimination based approach
[3] and soft computing based approach [2]. Let us now focus
[1,1] [1,2] [1,3] [1,4] [1,5] [1,6] [1,7] [1,8] [1,9] to review the elimination based approach. In this approach,
based on the given clues a list of possible values for every
[2,1]

[3,1]
1
[2,2]

[3,2]
[2,3]

[3,3]
[2,4]

[3,4]
2
[2,5] [2,6]

[3,5] [3,6]
[2,7]

[3,7]
3
[2,8]

[3,8]
[2,9]

[3,9]
blank cell is first obtained. Then using the following
different methods such as naked single, hidden single, lone
ranger, locked candidate, twin, triplet, quad, X-wing, XY-
[4,1] [4,2] [4,3] [4,4] [4,5] [4,6] [4,7] [4,8] [4,9] wing, swordfish, coloring, we eliminate the multiple
possibilities of each and every blank cell, satisfying the

[6,1]
46
[6,2]
1
[6,3] [6,4]
5[6,5] [6,6] [6,7]
6
[6,8]
7
[6,9]
constraints that each row, column, and minigrid should have
the numbers 1 through 9 exactly once. An instance of a
Sudoku puzzle and its possible values of each blank cell are
9 8 7 6 5 shown in Figures 3(a) and 3(b), respectively.

[9,1]
77
[9,2] [9,3] [9,4]
8 5
[9,5]
6
[9,6]
9
[9,7]
9
[9,8] [9,9]
2.2 Naked single
If there is only one possible value existing in a blank cell,
then that value is known as a naked single [2]. After
Figure 2. The structure of a 99 Sudoku puzzle (problem) with its nine assigning the probable values for each blank cell, as shown
minigrids of size 33 each as numbered (in grey outsized font) 1 through 9. in Figure 3(b), we obtain the naked singles 3, 9, and 3 at
Representation of each cell of a Sudoku puzzle and some example givens locations [5,2], [5,8], and [8,3], respectively. So, we can
(or clues coloured by red) in the remaining cells. So, the cells are [1,1]
through [9,9], and the distinct cells may have some clues as well. Minigrid
directly assign these values to these cells. Then we eliminate
numbered 1 consists of the cell locations [1,1], [1,2], [1,3], [2,1], [2,2], these digits (or naked singles) from each of the
[2,3], [3,1], [3,2], and [3,3], minigrid numbered 2 consists of the cell corresponding row, column, and minigrid. Hence, after
locations [1,4], [1,5], [1,6], [2,4], [2,5], [2,6], [3,4], [3,5], and [3,6], and so elimination of these numbers, as stated above, we obtain a
on.
modified (reduced) status of each blank cell as shown in
Now we review on the backtracking technique that has been Figure 3(c), wherein several other naked singles could be
adopted for solving Sudoku puzzles [3]. found (and this process is recursive until no naked singles
are found).
2.1 Backtracking
The basic backtracking algorithm works as follows. The 2.3 Hidden single
program places number 1 in the first empty cell. If the choice Sometimes there are blank cells that do, in fact, have only
is compatible with the existing clues, it continues to the one possible value based on the situation, but a simple
second empty cell, where it places a 1 (in some other row, elimination of candidate in that cell’s row, column and

Copyright (c) 2014 International Journal of Computer Science Issues. All Rights Reserved.
IJCSI International Journal of Computer Science Issues, Vol. 11, Issue 2, No 1, March 2014
ISSN (Print): 1694-0814 | ISSN (Online): 1694-0784
www.IJCSI.org 249

minigrid does not make it obvious. This kind of possible Figure 3. (a) An instance of a Sudoku puzzle. (b) Potential values in each
blank cell are inserted based on the given clues of the Sudoku instance in
value is known as a hidden single [3]. Suppose, if we re- Figure 3(a); here green digits are naked singles. (c) The concept of naked
examine the possible values in each cell of Figure 3(b), singles is preferably used to reduce the domain of probable candidate values
hidden single can easily be found in cell [7,2] whose value in each blank cell, and the process is successive in nature to find out
must be 4 as in minigrid numbered 7, 4 is not there as consequent naked singles, as much as possible. As for example, the naked
single for cell [9,8] is 2, as 4 and 8 have already been recognized as naked
probable values in other cells. Similarly, for cell [4,9], the singles along row 9 and column 8; then 8 is a naked single for cell [7,8], as
hidden single is 6 (as in other cells of the same minigrid 6 is 2 and 4 are already identified naked singles along column 8, and so on.
not present as probable values). Most of the puzzles ranked
as easy, extremely easy, and medium can simply be solved 2.4 Lone ranger
using these two techniques of singles. Lone ranger is a term that is used to refer to a number that is
one of multiple possible values for a blank cell that appears
2 6 8 5
only once in a row, or column, or minigrid [3]. To see what
4 5 7 3
this means in practice, consider a row of a Sudoku puzzle
2
with all its possibilities for each of the cells (red digits are
either givens or already achieved), as shown in Figure 4. In
7 5 1
this row, six cells (with red digits) have already been filled
4 6 8
5 2 in, leaving three unsolved cells (second, eighth, and ninth)
6 1 7 with their probable values written in them.

9 8 7 6 5
3 6
7 5 6 9
2 7 4 1 5 9 8 6 7 6 7

(a)

1 3 134 1 4 Figure 4. An example row of a Sudoku puzzle with a lone ranger 3 in the
9
1 3 2 6 8 79
1 4 5 9 second cell.
1 6
4 5 7 1 9 1 9 2 1 7 8 8 9 Notice that the second cell is the only cell that contains the
1 3 6 1 3 3 6 1 3 4 1 3 4 1 3 4 1 2 247 146 possible value 3. Since none of the remaining cells in this
8 9 8 8 9 5 7 9 7 9 5 7 9 4 6 89 89 row can possibly contains 3, this cell can now be confirmed
2 3 3 8 2 3 2 3 3 4 with the number 3. In this case, this 3 is known as a lone
7 8 9 4 9 4 9 8 9 5 1 3 6
ranger.
1 3 1 3
5 3 4 7 9 6 7 9
8 9 2
2 3 2 34 2 3 3 4 5 2 4 5 8 7 9 3 4 5 1 6
8 9 6 1 5 9 4 9 8 9
3 4 4 9 7
4 6 4 6
1 2 3 1 2 3 3 5 1 2 3 1 2 3 1 3 4 1 2 2 4 1 3 9 9 1 8 2 5 7 4 9 3
8 9 4 8 6 8 4 7 9 4 7 9 7 9 3 4 8 4 8
3 5
1 2 1 2 1 3 9 5 3 9 1 4 6 8 5 9 2
3 9 3 8 3 4 4
7 6 5
1 4 4 5 3 4
1 2 1 2
5
2 4 1 3 5 6 7 5 3 6 9 2 8 1 4
3 8 7 3 8
3 4 6 9 8 4 8
6

(b) 4 5 3 2 4 5 1 8 9 6 7
1 3 134 7 1 4 1 4 5 4 6 3 4 3 4
1 2 6 8 9
1 4 5 6 9 8 9 2 3 6 7 5 5 1 4
9 9
1 6
4 5 7 1 9 1 9 2 1 7 8 8 9 3 4 2 5 6 8 1 3 4 7 9
1 3 6 6 8 1 3 4 1 3 4 1 3 4 1 2 2 4 7 1 4 6
1 8 4 6 3 4
8 9 9 5 7 9 7 9 5 7 9 4 6 8 8 9
7 9 6 9 3 9 5 2 1 3 4 8
2 3 2 3 3 4
7 2 8 8 9
4 9 4 9 8 9 5 1 3 6
8 1 3 9 3 9 7 4 6 2 5
5 3 4 1 7 6 1 7 8 9 2
Figure 5. A Sudoku puzzle with probable locked candidates in the last row
2 8 2 34 2 3 3 4 5
9 6 1 5 9 4 9 8 9
3 4 4 7 of minigrid 6 (and here the locked candidates are 3 and 5 in cells [6,7] and
[6,8]), in the first column of minigrid 8 (and here the locked candidates are 9
1 2 8 1 2 4 5 6 1 2 3 1 2 3 1 3 4 1 2 2 4 1 3 and 3 in cells [8,4] and [9,4]), and so on.
9 8 8 4 7 9 4 7 9 7 9 3 4 8 4 8
1 2 2.5 Locked candidate
1 2 9 3 8 4
1 4 7 6 5
Sometimes it can be observed that a minigrid where the only
1 2 1 2 2 4 1 3
8 7 8 3 4 5 6 9 8 4 8 possible position for a number is in one row (or column)
(c)

Copyright (c) 2014 International Journal of Computer Science Issues. All Rights Reserved.
IJCSI International Journal of Computer Science Issues, Vol. 11, Issue 2, No 1, March 2014
ISSN (Print): 1694-0814 | ISSN (Online): 1694-0784
www.IJCSI.org 250

within that block, although the position is not fixed for the possible values for other blank cells. Triplet has several
number. That number is known as a locked candidate [2]. variations like the following.
Since the minigrid must contain the number in a row (or
Variety# 1: Three cells with same three possible values, as
column) we can eliminate that number not as a probable
shown in Figure 7(a).
candidate along the same row (or column) in other minigrids.
Consider the Sudoku puzzle along with its probable Variety# 2: Two cells with same three possible values and
assignments for each blank cell, as shown in Figure 5. It can the other cell containing any two of the possible values, as
readily be found that minigrid numbered 6 should have 3 in shown in Figure 7(b).
the last row. So we can simply eliminate number 3 from cell
[6,5] of minigrid numbered 5. Similarly, minigrid numbered Variety# 3: One cell with three possible values and the two
other cells containing two different subsets of two possible
8 should have 3 in its first column. So, 3 can be eliminated
as a possible candidate from cell [4,4]. values of the former three values, as shown in Figure 7(c).
Once a triplet is found, we can eliminate all the values of the
2.6 Twin triplet that are there as possible candidates in other blank
If two same possible values are present for two blank cells in cells along the same row (or column) and in the same
a row (or column) of a Sudoku puzzle, they are referred to as minigrid.
twin [3]. Consider the partially solved Sudoku puzzle as
shown in Figure 6(a). Observe the two cells [2,5] and [2,6].
4 5 2 4 5 4 5
They both contain the values 2 and 3 (means either 2 or 3). 7 6
9 8 1 3 6 6
So, if cell [2,5] takes value 2, then cell [2,6] must contain 3,
or vice versa. This type of situation is an example of twin. 7(a)

4 7 2 3 2 3 3 4 3 4 3 4 4 5
5 8
6 8 9 8 9
1 5 5 5 7 9 8 1 2 3
4 5
4 5
6 6
2 4 2 4 2 3
5 5 7 2 3 6 9
7(b)
9 3 1 6 4 5 2 8 7
4 5
2 3 7 4 5 9 8 1 2 3 4 6
1 2 4 7 5 2 3 7 8 9 4
6

7(c)
6(a)
Figure 7. Example rows of Sudoku puzzles with different varieties of triplet.
(a) A triplet of Variety# 1 with same three possible values present in three
4 7 2 3 2 3 3 4 3 4 3 4
5 8 6 8 9 8 9
1 5 5
cells. (b) A triplet of Variety# 2 with same three possible values present in
5
two cells and the other cell containing any two of them. (c) A triplet of
2 4 2 4 2 3 Variety# 3 with three possible values present in one cell and the two other
5 8 5 7 2 3 1 6 9 cells containing two different subsets of two possible values of the earlier
three values.
9 3 1 6 4 5 2 8 7
2.8 Quad
1 2 4 7 5 2 3 7 8 9 2 3
4
Analogous to triplet, a quad consists of a set of four possible
values and these values are present in some form in four
6(b) blank cells in a row (or column) of the Sudoku instance [3].
That is, if the values only exist in four (blank) cells in a row
Figure 6. (a) A partial Sudoku instance with presence of twin 2 and 3 in (or column), while each cell contains at least two of the four
cells [2,5] and [2,6]. (b) Elimination of probable values (that are 2 and 3)
based on the twin from the second row (2 is deleted from cells [2,1] and
values, then other values (or numbers except the specified
[2,3]) and from the same minigrid (2 and 3 are deleted from cells [1,4] and four values) can be eliminated from each of the assumed
[1,5]). cells (forming the quad). Figure 8 shows a row of a Sudoku
puzzle where the quad comprising the digits 1, 2, 4, 7 formed
Once a twin is identified, these values can be eliminated by by the cells in column four, six, seven, and eight. So other
striking through from the same row, column, and minigrid as possible values can straightway be eliminated from these
shown in Figure 6(b), as the values can not be probable cells, as shown by striking through the inapplicable digits in
candidates in other blank cells along the same row (or the figure.
column) and in the same minigrid.
2.7 Triplet 1 2 1 2 1 4
1 2
3 5 8 9
4 7
1 8
4 8 7 8
7 8 6
If three cells in a row (or column) are marked with a set of 9
same three possible values, they are referred to as triplet [3].
Like twins, triplets are also useful for eliminating some other

Copyright (c) 2014 International Journal of Computer Science Issues. All Rights Reserved.
IJCSI International Journal of Computer Science Issues, Vol. 11, Issue 2, No 1, March 2014
ISSN (Print): 1694-0814 | ISSN (Online): 1694-0784
www.IJCSI.org 251

Figure 8. An example row of a Sudoku puzzle with quad comprising digits 2. 10 XY-Wing
1, 2, 4, and 7 present in columns four, six, seven, and eight. To support the
digits present in the quad in the stated cells, other probable values (like 8 If a Sudoku puzzle has three cells containing the list of
and 9 in columns six, seven, and eight) are eliminated from these cells of the probable candidate values in the following patterns: (1) all
quad, as these values (that are 8 and 9) cannot be probable digits for the
specified cells.
cells have exactly two candidates, (2) they share the same
three candidates in the form of xy, yz, and xz, and (3) one
2.9 X-Wing cell (the ‘stem’ of Y with candidates xy) shares a group with
the other two cells (the ‘branches’ of Y with candidates xz
The X-Wing [2] method can be applied when there are two
and yz). Then we can say that they form an XY-wing [1]. At
rows and columns for which a given value is possible to
that moment any other cell that shares a group with both
assign only to two blank (diagonal) cells. If these four cells
‘branch’ cells can have excluded the ‘z’ candidate that is
are only at the intersections of two orthogonal rows and
common to the ‘branch’ cells. Consider the Sudoku puzzle
columns, then all other cells along these rows and columns
shown in Figure 10, as pointed out, the cells [1,2], [1,7], and
must not get assigned to this value. Figure 9 shows a Sudoku
[6,7] contain the list of probable candidate values as {1,8},
puzzle where 2 is present as probable value for cells [3,2],
{1,5}, and {5,8}, respectively. So the values of x can be
[3,8], [7,2], and [7,8]. It forms an X-Wing. So 2 can be
assumed as 5, y as 1, and z as 8. Now, irrespective to cell
eliminated as probable candidate value for other cells in the
[1,7] contains the value 1 or 5, the cell either [1,2] or [6,7]
same row and column. In this example we can eliminate 2 as
will have 8. Therefore, the intersection of these two cells,
probable candidate for cells [3,1], [3,3], [3,9], [7,1], [7,3],
i.e., [6,2] cannot have 8, i.e., z as a probable candidate. We
and [7,9].
can easily eliminate z from the intersection of the cell
3 4 containing xz and yz.
3 8 3 5 9 7 2 5 8
5 8 6 3 5
In the case above, the cells XZ and YZ share a common row
1 2
5 6 4 1 3 1 3 9 1 7 8 3 7 or a common column with the cell XY. It may also be a case
1 2 3 2 3 1 3 4 1 3 4 1 3 4 1 5 2 4 1 2 3
that it shares a minigrid as well. Consider the partial Sudoku
1 2
7 8 7 5 6 8 5 8 5 6 8 7 9 5 9 5 7 puzzle structure shown in Figure 11.
3 5 3 5 2 3
4 2 9 2 3
8 9 8 9 5 8 6 1 7 8

6 8 5 1 4 7 1 4 2 3 XY YZ
9
2 3 3 5 6 3 5 2 3 5 5 9 XZ
9 7 1 8 9 8 9 6 8
5 8 4
1 2 1 2 2 6 1 3 4 1 3 4 1 3 4 1 5 2 5 1 2
3 9 5 9 7 5 8 9 5 8 9 5 8 8 9 9 5 8
Figure 11. A Sudoku puzzle structure with XY-Wing, sharing minigrid.
1 5
1 9 3 8 2 9
1 5 4 7 6 Here the cell containing XZ shares a minigrid with cell
1 2 1 5 2 5 1 2 containing XY, and the cell containing YZ shares a common
4 2 6 7 3
9 8 9 9 5 8 row with the cell having XY. In this case, all the cells
marked grey color cannot contain Z as a probable candidate.
Figure 9. A Sudoku puzzle with X-Wing comprising digit 2 present at the Because if X is assigned in cell [2,2], then Z must be
crossings of rows three and seven, and columns two and eight. assigned to cell [3,1], then cells [3,4], [3,5], [3,6], [2,1], [2,3]
cannot have Z. Similarly, if Y is assigned to cell [2,2], then Z
1 3 1 3 4 1 3 also cannot be assigned to all these cells.
8
1 8 9 7 2 5 8
1 5 6 5

5 6 4 1 3 1 3 9 1 7 8
1 2 2.11 Swordfish
3 7
1 2 2 3 1 3 4 1 3 4 1 3 4 1 5 2 4 1 2 3 Swordfish [1] is a generalization of X-wing. If a digit is a
3 8 1 2
7 5 6 8 5 8 5 6 8 7 9 5 9 5 7 candidate for at most three cells in each of three different
3 5 3 5 3 5 columns and the positions of the cells fall into the same three
2 9 2 3 6 1 7 8
8 9 8 9 8 rows, then this digit cannot be a candidate for any other
6 4 5 1 8 7 1 8 columns in the three matching rows.
2 3 9
In Figure 12, in the first, fifth, and seventh column the
3 8 3 5 6 3 5 3 5
7 1 8 9 8 9 6 8
5 8 5 4 element 4 appears in the list of probable candidate values in
the same three rows (i.e., the first, seventh, and eighth row)
1 2 1 2 2 6 1 3 4 1 3 4 1 3 4 1 5 2 5 1 2
3 9 5 9 7 5 8 9 5 8 9 5 8 8 9 9 5 8 and 4 is not a member of any other rows of the columns. So,
1 5
this is a swordfish pattern. Now the digit, i.e., 4, can safely
1 9 3 9 8 2 9
1 5 4 7 6 be eliminated from other cells in the same rows. In the above
1 5 1 5 figure, 4 can be removed not as a probable candidate from
1 9 7 2 8 9 6 2 3 5 9
8 cell [1,8], and [8,4] as highlighted with green colour.

Figure 10. A Sudoku puzzle with XY-Wing, where x = 5, y = 1, and z = 8.

Copyright (c) 2014 International Journal of Computer Science Issues. All Rights Reserved.
IJCSI International Journal of Computer Science Issues, Vol. 11, Issue 2, No 1, March 2014
ISSN (Print): 1694-0814 | ISSN (Online): 1694-0784
www.IJCSI.org 252

can find that 1 and 6 appear exactly two times in the sixth
9 6 1 2 4 5 3 4 5 4 7 8 column. Let us assign a separate colour, say green colour, for
7
these cells.
1 6 2 5 2 6 2 6
8 4 3 7 1 5
9 9 9 Now let us follow the path as shown by arrow marks and
5 2 4 6 8 9 3 1 we can easily find the intersection between these yellow and
7 4 6
green coloured cells, and it is marked as blue. We can easily
1 7 9 4 8 6 7 9 5 3 conclude from all these that 6 cannot be present in the blue
2
coloured cell and we can easily eliminate 6 as a probable
2 6
3 6 3 7 5 1 9 4 8 7
2 6 candidate from the blue coloured cell. The example shows an
4 6 4 6
elimination technique using multi-colouring method. It can
2 8 6 9 3 7 5 1 9 9 also be used to confirm the value for a cell as well.
4 6 1 9 8 5 2 1 6 4 9 3 7
3. Comparison Among Different Sudoku
3 4 1 3 2 6 4 6
6 9 9 9
1 4 7 2 4
9 8 5 Solving Techniques
2 4 In the preceding section, we have discussed the most
7 5 2 9 4 9 3 8 6 1 9 fundamental method of backtracking and eleven different
elimination based techniques used for solving a given Sudoku
Figure 12. A Sudoku puzzle with swordfish occurred at the first, fifth, and puzzle. The basic backtracking method first assigns some
seventh column.
random variable to a blank cell, and then it goes on checking
2.12 Colouring with other cells if a value previously assigned to that cell hits
a conflict with other cell. If it hits with a conflict, then it
If a digit is a candidate for exactly two cells in a row, in a backtracks to the previous cell and assign the next value. In
column, or in a minigrid, then the technique of colouring [1] this way, the method may sometimes backtrack several times
may be very much dominant to make decisions to eliminate a before advancing. But, it is guaranteed to find a solution if
probable candidate from a cell or to confirm a digit for a cell. there is one, simply because it eventually tries every possible
There are several alternatives to colour a cell starting from number in every possible location. This method is very much
single colouring to multi-colouring. Let us state a simple time consuming.
multi-colouring technique. Consider the following Sudoku Instead of assigning a value to a cell based on guess, in the
puzzle as shown in Figure 13. elimination based approach a list of probable candidate values
are maintained for each of the blank cells. Then the different
1 2 7 3 4 patterns are searched using the different elimination based
6 9 8 9 5 6 8
techniques such as naked single, hidden single, locked
3 4 3 4 1 4 1 6 candidate, lone ranger, twin, triplet, quad, X-wing, XY-wing,
3 9
6 6 9 6
7 8 5 6 8 2 swordfish as described in the previous section. Some of these
techniques are able to directly assign some values in a cell.
5 4 6 8 4 6 3 2 1 9 7 Some of them can only eliminate values from other cells
present in the same row, column or minigrid. For example
1 6 1 5
2 7 1 6 5 6
7 9
2 9 3 8 4 9
using naked single, hidden single, or colouring, we can
directly assign some value for a particular cell. Whereas using
1 3 3 4
8 4 6 6 5 4 9 1 6 2 7 1 9 the other methods, we can only eliminate the candidate values
from other cells, as described in the previous section.
2 4 6
2 7 9 4 5 1 7
8
1 8 3 1 5 But these elimination based methods are also very much
time consuming as each of them has to search for a particular
6 7 1 8 5 9 4 2 3 pattern and also several backtracking is needed for solving a
puzzle. It may not also be necessary to apply all the methods
3 9 5 3 9 2 6 4 7 1 8 for solving a Sudoku puzzle. Generally, up to medium
difficulty level puzzles are solvable using only naked single,
4 8 2 3 1 7 9 5 6 hidden single, locked candidate, lone ranger, twin, triplet,
and quad based techniques. Rests are advanced techniques,
Figure 13. A Sudoku puzzle with multi-colouring for cells [2,4], [2,6], [3,2], which are essentially used for difficult and evil puzzles.
[3,4], and [5,6].
5. Conclusion
Let us consider the second minigrid of the puzzle shown In this paper, we made an attempt to study all the existing
in Figure 13, digits 4 and 6 are candidates for exactly two elimination based methods for solving the Sudoku puzzle.
cells [2,4] and [3,4]. Let us allocate yellow colour for these Apart from elimination based schemes, soft computing based
cells. Then we can also find that in the third row, 4 and 6 techniques are also available. But all these existing methods
also appear two times at row cell number [3,2] and [3,4], and are guess based and hence time consuming as well. Based on
let us again mark these cells with yellow colour. Again we

Copyright (c) 2014 International Journal of Computer Science Issues. All Rights Reserved.
IJCSI International Journal of Computer Science Issues, Vol. 11, Issue 2, No 1, March 2014
ISSN (Print): 1694-0814 | ISSN (Online): 1694-0784
www.IJCSI.org 253

the levels of difficulty, different methods are applied one after Dr. Sudipta Roy completed his M.C.A and M.E. in the year
another to find a valid solution of a Sudoku puzzle, if any. In of 2002 and 2005 respectively. He obtained his Ph.D. degree
addition, each of these existing solvers solves an instance of in the year of 2010. Currently he is working as Associate
the problem considering the clues one-by-one for each of the Professor in the Department of Information Technology,
blank cell locations. Often guessing may not be guided by Assam University Silchar, India. His research interests
selecting a desired path of computing a solution and hence includes Image Processing, Algorithm, Sensor Networks etc.
exhaustive redundant computations are involved over there. Dr. Roy published more than 40 research papers in various
National and International Journals.
References
[1] http://www.geometer.org/mathcircles [Last accessed on Dr. Rajat K. Pal. He received his B.E. and M.Tech. degree
Feb. 2014] respectively in 1985 and 1988, and awarded Ph.D. degree
[2] Jussien N., A-Z of Sudoku, USA: ISTE Ltd., 2007. from IIT, Kharagpur in 1996. He is serving the University of
[3] Lee W.-M., Programming Sudoku, USA: Apress, 2006. Calcutta as a faculty in the Department of Computer Science
[4] Yato T. and T. Seta, “Complexity and Completeness of and Engineering since 1994, and worked as the Head of the
Finding Another Solution and Its Application to Puzzles,” Department during 2005-2007. Dr. Pal has published more
IEICE Transactions on Fundamentals of Electronics, than 100 research articles and authored a book entitled
Communications, and Computer Sciences, Vol. E86-A, “Multi-Layer Channel Routing: Complexity and
No. 5, 2003, pp. 1052–1060. Algorithms” that has jointly been published from NAROSA
Publishing House, New Delhi, CRC Press, Boca Raton,
Arnab Kumar Maji completed his B. Tech and M.Tech in USA and Alpha Science International Ltd, UK, in
the field of Information Technology in the year of 2003 and September 2000. His major research interests include VLSI
2005 respectively. He is currently a senior research scholar design, Graph theory and its applications, Perfect graphs,
of Information Technology department of Assam University, Logic synthesis, Design and analysis of algorithms,
Silchar. He is working as an Assistant Professor of North Computational geometry, Parallel computation and
Eastern Hill University, Shillong, Meghalaya, India since algorithms.
2006. He has published more than 20 numbers of research
paper in the field of algorithm, image processing and e-
commerce. He is a professional member of ACM India.

Sunanda jana completed his B.Tech from Biju patnaik


University of technology and M.Tech from Berhampur
University in the year of 2007 and 2010 respectively.
Currently she is working as an Assistant Professor
Department of Computer Science, Haldia Institute of
Technology, Haldia, Westbengal, India since 2011. Her
research interest includes Algorithm, NP complete Puzzles
etc.

Copyright (c) 2014 International Journal of Computer Science Issues. All Rights Reserved.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy