X-Wing and Swordfish: Sudoku Fish Patterns Made Simple
How the X-Wing and Swordfish work in sudoku, in rows and in columns, how to scan for them, and worked examples you can check, plus one to try.
An X-Wing in sudoku is a pattern for one digit: in two rows, the digit has exactly two possible squares each, and those squares sit in the same two columns. The digit must then fill those two columns from those two rows, so it can be removed from every other square in the two columns. A Swordfish is the same idea with three rows and three columns. Both also work with rows and columns swapped. This guide is for solvers who already use notes, pairs and pointing.
The idea: two rows, two columns, one digit
The X-Wing rests on one simple counting argument. Each row needs the digit once. If in row A the digit can only go in column 3 or column 8, and in row B it can also only go in column 3 or column 8, then the two rows take one column each. There are only two ways that can happen: row A takes column 3 and row B column 8, or the other way round. The two ways are the two diagonals of a rectangle, which make an X.
Either way, column 3 gets its digit from row A or row B, and so does column 8. No other square in those two columns can hold the digit. SudokuWiki states the rule like this: when a value has only two possible cells in each of two different rows, and these candidates lie in the same columns, all other candidates for that value in those columns can be eliminated (SudokuWiki: X-Wing).
Fish patterns, as X-Wing, Swordfish and their bigger cousin Jellyfish are called, are about one digit only. So the clearest way to see them is a candidate map: the grid with every note erased except one digit. The diagrams below use that view. In each, # is the digit already placed, the digit itself marks a square where it is still possible, highlighted squares are the pattern, and x marks the candidates the pattern removes. Rows are numbered from the top and columns from the left, so R6C2 is row 6, column 2.
Each map below is one digit of a puzzle in progress. You can check any of them the slow way: list every legal way to place the digit on the map, one per row, column and box, and see that the squares marked x are never used.
An X-Wing in rows, step by step
Here is the candidate map for the digit 4 in a 9x9 puzzle. Three 4s are placed, in the bottom three rows; the top six rows still need theirs.
Work through it:
- Find two rows with exactly two candidates. Row 2 has 4 in R2C2 and R2C9. Row 4 has 4 in R4C2 and R4C9.
- Check that they line up. Both rows use columns 2 and 9. That is the rectangle.
- Draw the conclusion. Row 2's 4 is in column 2 or 9, and row 4's 4 is in the other one. So column 2's 4 comes from row 2 or row 4, and so does column 9's.
- Remove. Every other 4 in columns 2 and 9 goes: R6C2 in column 2, and R3C9, R5C9 and R6C9 in column 9.
Four candidates disappear. The rows in the pattern keep their candidates; only the columns are cleaned. After the removals, the right-hand box of the middle band (rows 4 to 6, columns 7 to 9) has only R4C9, R5C8 and R6C8 left for its 4, which is much closer to a single.
The same pattern in columns
An X-Wing works just as well with columns as the base: two columns in which the digit has exactly two squares, in the same two rows. Then the digit is removed from the rest of those two rows.
Column 3 can only take its 3 in R3C3 or R5C3, and column 4 in R3C4 or R5C4. Between them they use up the 3s of rows 3 and 5. So R3C2 and R3C7 cannot be 3. Row 5 has nothing else to remove, which is common: an X-Wing often removes only one or two candidates, and that is enough.
The lesson is to scan both ways. A digit that shows no row X-Wing may still have a column one, as here.
Swordfish: the three-line version
A Swordfish is three rows in which a digit's candidates all fall within the same three columns. Each row can have two or three candidates, so the pattern need not be a full 3x3 block. SudokuWiki gives the name 2-2-2 Swordfish to the shape where each line has only two (SudokuWiki: Swordfish).
The three rows:
| Row | Possible squares for 9 |
|---|---|
| 3 | Column 1 or column 5 |
| 5 | Column 5 or column 9 |
| 9 | Column 1 or column 9 |
No two rows share both columns, so there is no X-Wing. But the three rows together use only columns 1, 5 and 9. Follow the cases. If row 3 takes column 1, row 9 must take column 9, and row 5 column 5. If row 3 takes column 5, row 5 must take column 9, and row 9 column 1. In both cases the three rows fill all three columns. So the 9s of columns 1, 5 and 9 all come from rows 3, 5 and 9, and R1C1, R1C5, R7C1 and R7C9 lose their 9.
A Swordfish also works with columns as the base. Suppose that in a different puzzle the digit 9 could go only in rows 6 and 8 of column 1, rows 7 and 8 of column 5, and rows 6 and 7 of column 8. Three columns, confined to rows 6, 7 and 8, so the 9 leaves the rest of those rows. If R6C4, R6C6, R6C9, R8C3 and R8C9 still held a 9, all five would lose it at once.
Fish by size
All fish follow the same rule: N rows whose candidates for a digit fall within N columns (or the reverse) let you clear that digit from the rest of those N columns.
| Fish | Lines | Candidates per line | Squares in the pattern |
|---|---|---|---|
| X-Wing | 2 | Exactly 2 | 4, the corners of a rectangle |
| Swordfish | 3 | 2 or 3 | 6 to 9, within a 3x3 set of crossings |
| Jellyfish | 4 | 2 to 4 | 8 to 16, within a 4x4 set of crossings |
SudokuWiki explains why the list stops there: a five-line fish always leaves a four-line fish in the remaining lines, so you never need anything bigger. It also notes that all Swordfish break down into X-Wings logically, which is why the bigger fish are just as safe (SudokuWiki: Swordfish).
There are also finned fish, where one or two extra candidates (the fin) spoil a clean X-Wing. If you can form the X-Wing by ignoring the fin, you may still remove a candidate that the X-Wing would remove, but only one that shares a box with every fin square (SudokuWiki: finned X-Wing). Learn the plain versions first.
How to scan for X-Wings and Swordfish
Scanning for fish is a one-digit job, so take the digits in turn. A routine:
- Pick a digit. Start with one that has several copies placed: fewer open lines means a smaller map to read.
- List the rows where it has two spots. For each, write down the two columns, for example "row 2: 2 and 9".
- Look for a matching pair. Two rows with the same two columns are an X-Wing. Check whether those columns hold any other candidates for the digit; if not, there is nothing to remove.
- Look for three rows sharing three columns. Rows with two or three spots whose columns together make only three are a Swordfish.
- Repeat with columns. List the columns where the digit has two spots and their rows.
- Back to singles. After removing, check the boxes and lines that lost candidates.
Your notes must be complete for the digit you are scanning. A missing candidate can make a fake X-Wing, and a stale one can hide a real one. If you use two-square notes, where you mark a digit only when it has two spots in a box, fill in the full candidates for the digit before you look for fish; sudoku notes and pencil marks covers the styles.
Two common mistakes: rows that share only one of their two columns are no X-Wing; and a row with four candidates cannot join a Swordfish. Count the columns used across all the rows of the pattern. The count must equal the number of rows.
Try one yourself
Here is a candidate map for the digit 2. Before reading on, find an X-Wing and the squares that lose their 2.
The answer. Rows 1 and 9 each have 2 in exactly two squares, columns 5 and 8. That is the X-Wing. Column 5 has no other candidates, but column 8 does: R2C8 and R8C8 lose their 2. You could also have found it from the other side. Columns 6 and 7 each hold 2 only in rows 2 and 8, which is a column X-Wing, and it removes the same two candidates from rows 2 and 8. Rows 2 and 8 could not be the base, because each had three candidates. When two fish give the same removals, whichever you spot first will do, which is why scanning both ways pays.
Frequently asked questions
What is an X-Wing in sudoku?
An X-Wing is a pattern for one digit. Two rows each have exactly two possible squares for the digit, in the same two columns. The digit must then take those columns from those rows, so it can be removed from every other square in the two columns. It works the same with columns and rows swapped.
What is the difference between an X-Wing and a Swordfish?
An X-Wing uses two rows and two columns; a Swordfish uses three rows and three columns. In a Swordfish each row may have two or three candidates, as long as all of them fall within the same three columns. The removals are in the crossing lines, exactly as for an X-Wing.
Can an X-Wing use boxes instead of rows or columns?
Rows and columns are the standard form. SudokuWiki notes that the idea can be extended to boxes, giving six combinations of unit types, but some of those turn out to be the same deductions as pointing and claiming. In practice, look for row and column X-Wings, and let pointing and claiming handle the boxes.
Do you ever need a Jellyfish?
Rarely, and only in very hard puzzles. A Jellyfish is the four-line version and works exactly like a Swordfish with one more line. Bigger fish are never needed, because a five-line fish always leaves a four-line fish in the other lines.
Where to go next
Fish sit just above pairs and triples on the ladder. If those are not yet automatic, read naked and hidden pairs first. Next come the three-square patterns, XY-Wing and XYZ-Wing, and simple colouring, which is a fish's cousin: it also follows one digit through the grid. All of them are in sudoku strategies, from singles to X-Wing.
To practise, play the Expert level of Puzzle Picnic's sudoku. Its solver, which checks every puzzle, knows X-Wing and Swordfish, and the harder levels need techniques beyond singles. If you get stuck, a hint explains the next logical step. More guides are on the sudoku topic page, and how to play sudoku has the basics.