Sudoku strategy - Cross Hatching

Cross-hatching is similar to squeezing but here, we will be using two or more solved numbers that are connected in different directions from our target box.

The graphic above shows an example of cross-hatching. The solved 7s from box G eliminate the possibility of 7 from column 2 while the solved 7 from block C eliminate the possibility of 7 from row 1. The only cell left in block A is R3C1 and hence must be 7.

Could you determine where the 7s are in blocks E and I using cross-hatching?

The single spotted using squeezing or cross hatching is also known as hidden single.

Sudoku strategy - Squeezing

Squeezing utilizes one or two solved numbers in connected boxes to locate the same number in the third connected box. Consider the band (3 horizontally connected boxes) shown above. The number 4 is already solved in the last two boxes. The green color highlights all the squares on which a 4 is not permissible. In the third connected block, only one unsolved square is not highlighted by green, and since that's the only square left, it must be a 4.

The graphic above shows an example of when one solved number is enough to obtain a squeezing solution.

Sudoku

Note: Sudoku terminologies are bolded.

The rule of Sudoku is simple: Fill in the empty cells in the grid so that each row, column and box contains the number 1 to 9.

Notation
We will refer to a particular cell in the grid using the notation R#C#. For instance, the cell in the third row and fourth column is denoted as R3C4.

The 9 boxes of 3x3 will be labeled with A-I in the following manner:

The most systematic way to solve Sudoku is to meticulously maintain a list of possible candidates for each cell. This process is usually tedious, error-prone and detracts the fun out of Sudoku. For a start, we will look at some of the simple strategies. *The list here will be updated from time to time:

1) Squeezing.
2) Cross-hatching

Matlab vs Java

The first thing I tried yesterday was to translate the Matlab function for verifying a Sudoku puzzle into Java. That was the first time I realized how easy it was to code in Matlab compared to Java.

As a comparison, let's look the codes. For matlab, to check for duplicate values , here's the code:
k = find(A(i,:) == j);

It's just a single line and I only need to check the length of k next to determine whether duplicate values exist or. For Java, I have write a loop to get the desired result.

int[] count = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int value = 0;
// check for duplicate values
for(int i = 0; i <>
value = cells[i];
count[value] += 1;
if(value != 0 && count[value] > 1) {
return true;
}

Conclusion: Matlab beats Java with a resounding victory. Of course, that only applies when it comes to ease of programming.