← StudyX Devlog

What Is an X-Wing in Sudoku? An Intermediate Technique

Hiroki ObaraHiroki Obara · DeveloperSudoku365How-To
What Is an X-Wing in Sudoku? An Intermediate Technique

The X-Wing is a Sudoku technique that looks at a single digit. If that digit has only two possible cells in each of two rows, and those cells sit in the same two columns in both rows, you can erase the digit from every other cell in those two columns. The four cells form the corners of a rectangle, and the two diagonals make an X.

In Advanced Sudoku Techniques I showed the shape on an empty grid, next to the other techniques. This post works through one grid in the middle of a solve: listing the candidates, spotting the X-Wing, erasing, and the cell that gets settled as a result.

The words are the same as before: a row runs across, a column runs down, a box is one of the 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 3, column 2”.

The grid

Here is a puzzle partway through. It has one solution. A dot is an empty cell.

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

row 4   . . 8 | . . 5 | 7 6 .
row 5   . . . | 8 . 4 | 9 . 5
row 6   . . 5 | . 7 6 | 4 8 .

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

At this point no cell can be settled by looking for the only digit a cell can take, or the only place a digit can go in a box, row or column. So take the digit 2.

Where 2 can go

The rows still missing a 2 are row 1 and rows 3 to 6. In each of them, take the empty cells and drop any that already have a 2 in the same column or box. The cells left for 2 are marked o.

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

row 4   . o 8 | . o 5 | 7 6 o
row 5   . o o | 8 o 4 | 9 o 5
row 6   . o 5 | . 7 6 | 4 8 o

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

Row 3 has only two empty cells, in columns 2 and 9, and 2 can go in both.

Row 6 has four empty cells, in columns 1, 2, 4 and 9. Column 1 already has a 2 in row 9, and column 4 has one in row 7. That leaves columns 2 and 9.

So in both row 3 and row 6, the only places for 2 are columns 2 and 9. That is an X-Wing.

Erasing 2 from columns 2 and 9

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

row 4   . x 8 | . o 5 | 7 6 x
row 5   . x o | 8 o 4 | 9 o 5
row 6   . O 5 | . 7 6 | 4 8 O

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

The O cells are the four places for 2 in rows 3 and 6.

The 2 in row 3 goes in column 2 or column 9. If it goes in column 2, row 6 cannot use column 2 as well, so the 2 in row 6 goes in column 9. If row 3 takes column 9, row 6 takes column 2.

Either way, the 2 of column 2 is in row 3 or row 6, and so is the 2 of column 9. Those two rows use up the 2s of both columns. No other cell in column 2 or column 9 can hold a 2, so you can erase 2 from the x cells: row 1 column 2, row 4 column 2, row 5 column 2 and row 4 column 9.

You still do not know which of the two columns row 3’s 2 is in. What the X-Wing tells you is where 2 cannot go.

The cell that follows

Look at row 4. Its candidates for 2 were columns 2, 5 and 9. The X-Wing removed columns 2 and 9, so only column 5 is left. Row 4, column 5 is a 2.

An X-Wing on its own does not settle any cell. The erased candidates can leave a digit with only one place in another row, column or box. In this grid, that happened in row 4.

The same thing by columns

It works with rows and columns swapped. On the same grid, look at the columns this time.

Column 3 has only two empty cells, in rows 1 and 5. Column 8 has three, in rows 1, 5 and 9, but row 9 already has a 2 in column 1, so row 9, column 8 cannot be a 2. In both columns, the only places for 2 are rows 1 and 5.

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

row 4   . o 8 | . o 5 | 7 6 o
row 5   . x O | 8 x 4 | 9 O 5
row 6   . o 5 | . 7 6 | 4 8 o

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

The 2s of rows 1 and 5 are used up by columns 3 and 8. So you can erase 2 from the other cells of rows 1 and 5: the x cells at row 1 column 2, row 5 column 2 and row 5 column 5.

In column 5, 2 could go in row 4 or row 5. With row 5 erased, only row 4 is left. The column view settles the same cell, row 4 column 5, as the same 2.

How to look for one

Pick a digit and look for rows where it has exactly two candidates. When you find one, check whether another row has the same pair of columns. Do the same with columns: find columns with exactly two candidates, and look for another column with the same pair of rows.

Only the two rows forming the corners (or the two columns, in the column view) need exactly two candidates. The lines you erase from can have any number. In the example, column 2 had five candidates for 2.

If the shape is there but the other cells of those lines have no candidates for that digit, there is nothing to erase. Then move on to another digit.

An X-Wing depends on correct pencil marks. If you leave out one cell where 2 can go, a row with three places looks like a row with two. How to write marks is in How to Write Sudoku Pencil Marks, and an order for checking them is in Stuck on a Sudoku?. The Swordfish, which stretches the same idea to three rows, is in the advanced techniques post.

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