# The X-Wing technique

The X-Wing is usually the first advanced technique a solver learns, and one of the most useful. It follows a single digit across two rows or two columns and, when the pattern is there, clears that digit from cells far away from where you found it.

## What an X-Wing looks like

Pick one digit and look only at the cells where it can still go. An X-Wing appears when **two rows each have exactly two places** for that digit, and those places line up in the **same two columns**. The four cells form the corners of a rectangle.

When you find one, you can remove the digit from every other cell in those two columns. The rows are where you find the pattern; the columns are where you make the eliminations.

_Diagram: Every cell where 5 is still possible. Rows 2 and 7 (shaded) each have a 5 in only two cells, and both pairs sit in columns 3 and 8._

## Why the logic works

Row 2 needs a 5, and it can only go in r2c3 or r2c8. Row 7 also needs a 5, and it can only go in r7c3 or r7c8. That leaves exactly two possibilities:

- If r2c3 is 5, then r7c3 cannot be (same column), so row 7's 5 must be in r7c8.
- If r2c8 is 5, then r7c8 cannot be, so row 7's 5 must be in r7c3.

Either way, the two 5s sit on opposite corners of the rectangle, which is where the X in the name comes from. And in both cases, column 3 gets its 5 from row 2 or row 7, and so does column 8. No other cell in those two columns can hold a 5. You never need to know which diagonal is the right one.

## A worked example

Back to the grid. Column 3 also has a 5 pencilled in r4c3 and r9c3, and column 8 has one in r5c8. The X-Wing removes all three.

_Diagram: Columns 3 and 8 (shaded) take their 5s from rows 2 and 7, so the 5s in r4c3, r9c3 and r5c8 can be crossed out._

Rows 4, 5 and 9 still have other places for their 5, so nothing breaks; the grid just got simpler. After any elimination, check the rows and boxes you touched for new [hidden singles](https://drop.top/apps/sudoku/hidden-singles/): a digit often ends up with only one home.

## Rows or columns: it works both ways

Everything above also works turned on its side. If two **columns** each have exactly two places for a digit, and those places share the same two **rows**, you can remove the digit from the rest of those two rows.

A simple way to keep it straight: find the pattern in one direction, eliminate in the other. Two rows with the pattern clear two columns; two columns with the pattern clear two rows.

## How to spot an X-Wing

X-Wings are easy to miss if you look at the whole grid at once. Search one digit at a time:

1. Make sure your [pencil marks](https://drop.top/apps/sudoku/pencil-marks/) are complete for that digit. One missing candidate can create an X-Wing that isn't really there.
2. Go through the rows and note every row where the digit fits in exactly two cells.
3. Look for two of those rows whose cells sit in the same two columns.
4. Check those columns for other cells that still hold the digit. Those are your eliminations.
5. Repeat with columns, looking for two columns whose two cells share the same rows.

Digit highlighting, where an app shades every cell that can take the chosen digit, makes this much faster. On paper, it helps to run your pencil along each row and count.

## Common mistakes

- **Three cells in a row.** If one of the rows has the digit in three places, it is not an X-Wing. It may be part of a [Swordfish](https://drop.top/apps/sudoku/swordfish/).
- **Eliminating in the wrong lines.** When the pattern is in rows, the removals happen in the columns, never in the two rows themselves.
- **Checking the wrong lines.** The two pattern rows must have exactly two candidates each. The columns can hold any number; the extra ones are what you remove.
- **Trusting incomplete notes.** An X-Wing is only as reliable as your pencil marks. If you skipped a candidate, the pattern can look real when it is not.

If you know [pointing pairs](https://drop.top/apps/sudoku/pointing-pairs/) and [box-line reduction](https://drop.top/apps/sudoku/box-line-reduction/), try those first: they are quicker to find. The X-Wing is the next step up, and close relatives such as the [Skyscraper](https://drop.top/apps/sudoku/skyscraper/) and the [Two-String Kite](https://drop.top/apps/sudoku/two-string-kite/) use the same kind of reasoning.

## Questions

### Why is it called an X-Wing?

Because the two cells that end up holding the digit always sit on opposite corners of the rectangle, forming an X. Which diagonal it turns out to be doesn't matter for the elimination.

### Can an X-Wing be in columns instead of rows?

Yes. If two columns each have a digit in exactly two cells, and those cells are in the same two rows, remove that digit from the rest of those two rows.

### What is the difference between an X-Wing and a Swordfish?

A Swordfish is the same idea with three rows and three columns instead of two. The X-Wing is the two-row version and the easier one to spot.

### What is a finned X-Wing?

An X-Wing with one extra candidate, the fin, in one of the two rows. You can then only remove the digit from cells in the pattern's columns that also share a box with the fin.

### Do I need X-Wings to solve hard sudokus?

Often, yes. Easy and medium puzzles rarely need one, but puzzles rated hard or expert regularly do. See [sudoku difficulty levels](https://drop.top/apps/sudoku/difficulty-levels/).
