← StudyX Devlog

What Is a Unique Rectangle in Sudoku? A Technique Built on One Answer

Hiroki ObaraHiroki Obara · DeveloperSudoku365How-To
What Is a Unique Rectangle in Sudoku? A Technique Built on One Answer

The unique rectangle is a Sudoku technique with one unusual feature. It uses not only the rules, but also the promise that the puzzle has exactly one answer.

The post Every Sudoku Has One Answer described the idea in a few lines. This post takes one grid in the middle of a solve and goes through it step by step: why the pattern would give a puzzle two answers, and which candidates you can erase because of it.

The words are the same as in the X-Wing and Swordfish posts. A row runs across, a column runs down, a box is one of the nine 3×3 blocks, and a candidate is a digit that could still go in a cell. A cell is named by its row and column, as in “row 1, column 8”.

A rectangle with two answers

The HoDoKu solving guide, on its Uniqueness page, defines a unique rectangle as four cells that occupy exactly two rows, two columns and two boxes.

Say those four cells can only hold the same two digits, 3 and 8. Two cells in the same row must hold different digits, so the four cells alternate like this:

3 … 8
:     :
8 … 3

Now swap the 3s and 8s in all four cells.

  • Each of the two rows still has one 3 and one 8.
  • Each of the two columns still has one 3 and one 8.
  • The four cells sit two to a box in two boxes. In each box, the two cells hold a 3 and an 8, so the swap leaves the box’s contents unchanged.

Nothing else on the grid changes, so the swapped grid follows the rules too. As long as none of the four cells is a given, it also agrees with the clues. The puzzle would have two answers. The Unique Rectangles page on SudokuWiki calls this four-cell shape the “Deadly Pattern” and says that any Sudoku with it has two solutions.

In a puzzle with only one answer, this shape cannot appear in the final solution. The unique rectangle technique erases candidates so that the shape never forms.

Why it has to be two boxes

If the rectangle spreads over four boxes, things change. Take the four cells where rows 1 and 5 meet columns 5 and 8.

Now the box containing row 1, column 5 has only one cell of the rectangle. Change its 3 to an 8 and that box has no 3 left, and two 8s, because the box already had an 8 somewhere else. The swapped grid breaks the rules, so there is no second answer.

The four cells can never fit in a single box either. That box would hold two 3s and two 8s, which the rules forbid. This is why the HoDoKu definition says two boxes.

The HoDoKu page also notes that the logic does not apply if any of the four cells is a given. Givens cannot be swapped.

The example grid

The grid below is a puzzle partly solved. The puzzle has exactly one answer. A dot is an empty cell.

        1 2 3   4 5 6   7 8 9
row 1   5 7 2 | 4 . 6 | . . 9
row 2   8 3 6 | 9 5 1 | . 7 .
row 3   9 4 1 | 7 . 2 | 5 . 6

row 4   3 8 4 | . 7 9 | . 2 .
row 5   2 9 5 | . 1 4 | 7 . .
row 6   1 6 7 | . 2 3 | 9 4 .

row 7   6 1 8 | 2 9 7 | . 5 .
row 8   7 5 9 | 3 4 8 | . . .
row 9   4 2 3 | 1 6 5 | 8 9 7

There are 20 empty cells. No cell has a single candidate, and no digit has only one place left in any row, column or box.

The four cells

Look at the four cells where rows 1 and 3 meet columns 5 and 8. Rows 1 and 3 are in the top band, column 5 is in the middle box and column 8 in the right-hand box. The four cells span exactly two boxes.

        1 2 3   4 5 6   7 8 9
row 1   5 7 2 | 4 A 6 | . B 9
row 2   8 3 6 | 9 5 1 | . 7 .
row 3   9 4 1 | 7 A 2 | 5 A 6

row 4   3 8 4 | . 7 9 | . 2 .
row 5   2 9 5 | . 1 4 | 7 . .
row 6   1 6 7 | . 2 3 | 9 4 .

row 7   6 1 8 | 2 9 7 | . 5 .
row 8   7 5 9 | 3 4 8 | . . .
row 9   4 2 3 | 1 6 5 | 8 9 7

Here are their candidates.

  • Row 1, column 5: row 1 has 2, 4, 5, 6, 7 and 9, and column 5 has 1, 2, 4, 5, 6, 7 and 9. That leaves 3 and 8.
  • Row 3, column 5: row 3 has 1, 2, 4, 5, 6, 7 and 9. That leaves 3 and 8.
  • Row 3, column 8: row 3 again rules out 1, 2, 4, 5, 6, 7 and 9. That leaves 3 and 8.
  • Row 1, column 8: row 1 has 2, 4, 5, 6, 7 and 9, and column 8 has 2, 4, 5, 7 and 9. That leaves 1, 3 and 8.

The three cells marked A have only 3 and 8. The cell marked B, at row 1, column 8, has a 1 as well.

Erasing 3 and 8 from row 1, column 8

If the B cell were a 3 or an 8, all four cells would hold only 3 and 8. That is the two-answer shape from the first section. This puzzle has one answer, so it cannot happen. You can erase 3 and 8 from the B cell. Only 1 is left, so row 1, column 8 is 1.

HoDoKu calls this Type 1: only one of the four cells has extra candidates, and you erase the rectangle’s two digits from that cell.

Once row 1, column 8 is 1, the cell at row 1, column 7 has only 3 left. Then row 3, column 8 becomes 8, because the 3 at row 1, column 7 is in the same box. Row 1, column 5 becomes 8, and row 3, column 5 becomes 3. From there, filling cells that have a single candidate one after another solves the whole grid.

Checking without uniqueness

You can reach the same result without the one-answer promise. Put a 3 or an 8 in the B cell and follow what happens.

With a 3 in the B cell, row 1, column 7 becomes 1, and row 3, column 8 becomes 8 because column 8 now has a 3. Row 4, column 7 had 1 and 6, and with a 1 in column 7 it becomes 6. Now look at row 5, column 8. Its candidates were 3, 6 and 8. Column 8 has the 3 and the 8, and its box has the 6 at row 4, column 7. Nothing can go there.

With an 8 in the B cell, row 1, column 5 becomes 3, then row 1, column 7 becomes 1, row 3, column 8 becomes 3 and row 4, column 7 becomes 6. Again, row 5, column 8 has nothing left.

Both lead to a dead end, so row 1, column 8 is 1. The unique rectangle gets you to the same cell just by looking at the four cells’ candidates, with no trial. How to try a digit and look for a contradiction is covered in Is It OK to Guess in Sudoku?.

Only for puzzles with one answer

The SudokuWiki page says this technique takes advantage of the fact that published Sudokus have only one solution, and that if your source does not guarantee this, the technique will not work.

The HoDoKu page says most Sudoku players consider puzzles with more than one solution invalid. Even so, it notes a very heated argument over whether uniqueness techniques are valid. One view is that a puzzle should be solved from the rules alone. Another is that having one answer is part of what makes it a puzzle.

Besides Type 1, the HoDoKu page covers Types 2 to 6, where more than one of the four cells has extra candidates.

Like other techniques, this one depends on correct notes. If one of the three A cells is missing a candidate, you may see a rectangle where there is none. Writing notes is covered in How to Write Sudoku Pencil Marks.

About Sudoku365

Sudoku365 is a Sudoku app for iPhone, iPad and Android. It uses the classic 9×9 board. It has four difficulties, Easy, Medium, Hard and Expert, with 300 puzzles each, 1,200 in total. There is a Daily Challenge with one puzzle a day and a streak, and two people can play head to head or together over Bluetooth.

Turning notes on lets you write candidates in the cells. With “Remove numbers from notes” in the settings (on by default), placing a correct digit erases the same note from the related cells. Selecting a cell highlights its row, column and box, and every cell with the same digit.

The app is free with ads, and a one-time Remove Ads purchase turns them off. Ideas for keeping a daily habit on your own are in Sudoku365 Tips, and for your first puzzle, see Getting Started with Sudoku365.

Download on the App Store Download on Google Play

Sudoku365Daily sudoku, alone or with two