← StudyX Devlog

What Is a Swordfish in Sudoku? The X-Wing on Three Lines

Hiroki ObaraHiroki Obara · DeveloperSudoku365How-To
What Is a Swordfish in Sudoku? The X-Wing on Three Lines

The Swordfish is a Sudoku technique that looks at a single digit. If that digit has only two or three possible cells in each of three rows, and all of those cells together fit into three columns, you can erase the digit from every other cell in those three columns.

The X-Wing post used a rectangle made by two rows and two columns. A Swordfish stretches that to three rows and three columns. In Advanced Sudoku Techniques I only described the shape in words, so this post works through one grid in the middle of a solve: listing the candidates, spotting the Swordfish, 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 2, column 7”.

From two lines to three

SudokuWiki’s Swordfish page starts from the four corners of the X-Wing rectangle and calls the Swordfish “a 3 by 3 nine-cell pattern where a candidate is found on three different rows (or three columns)”. Those rows line up with three lines in the other direction.

HoDoKu’s page on Basic Fish calls the rows you check the base sets and the columns you erase from the cover sets. An X-Wing has two of each. HoDoKu says Swordfishes “work exactly the same way as X-Wings, just with three base and three cover sets”. On the same page, the version with four base and four cover sets is the Jellyfish.

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   6 7 5 | 2 1 4 | 3 9 8
row 2   3 4 8 | 7 6 9 | . 1 .
row 3   1 9 2 | 5 8 3 | 6 7 4

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

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

There are 29 empty cells. No cell has a single candidate, and no digit has only one place left in any row, column or box. There is no X-Wing on the digit 2 either. So take the digit 2.

Where 2 can go

The rows still missing a 2 are rows 2, 4, 5, 6, 8 and 9. 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   6 7 5 | 2 1 4 | 3 9 8
row 2   3 4 8 | 7 6 9 | o 1 o
row 3   1 9 2 | 5 8 3 | 6 7 4

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

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

Row by row, these are the columns where 2 can go:

  • Row 2: columns 7 and 9
  • Row 4: columns 2, 5, 6 and 7
  • Row 5: columns 2, 6, 8 and 9
  • Row 6: columns 6 and 7
  • Row 8: columns 5 and 8
  • Row 9: columns 6, 7 and 9

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

Row 9 has four empty cells, in columns 2, 6, 7 and 9. Column 2 has no 2, but the box of row 9, column 2 has a 2 in row 7, column 1. That leaves columns 6, 7 and 9.

Put rows 2, 6 and 9 together, and the only columns where they can hold a 2 are columns 6, 7 and 9. That is a Swordfish.

Erasing 2 from columns 6, 7 and 9

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

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

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

The O cells are the seven places for 2 in rows 2, 6 and 9.

Each of those three rows gets exactly one 2. No column can hold two 2s, so the three 2s go in three different columns, and all three are in columns 6, 7 and 9. There are only three ways this can turn out:

  • If row 2 has it in column 7, row 6 has it in column 6 and row 9 in column 9.
  • If row 2 has it in column 9 and row 6 in column 6, row 9 has it in column 7.
  • If row 2 has it in column 9 and row 6 in column 7, row 9 has it in column 6.

In every case, the 2s of columns 6, 7 and 9 are used up by rows 2, 6 and 9, one each. So no other cell in those three columns can be a 2. You can erase 2 from the four x cells: row 4, column 6; row 5, column 6; row 4, column 7; and row 5, column 9.

At this point you still do not know which of the three ways is the real one. Like the X-Wing, the Swordfish tells you where a digit cannot go.

Two or three candidates per row

In this grid, rows 2 and 6 have two places for 2, and row 9 has three. Of the nine cells where the three rows cross the three columns, seven can hold a 2.

The SudokuWiki page also says you do not need the digit in every cell. It calls an example with two candidates in each column a “2-2-2 Swordfish”, and it says that a “perfect” Swordfish, with candidates in all nine cells, is extremely rare.

What counts is that the candidates of the three rows, taken together, fit into three columns. If a row had only one place for the digit, that cell would already be settled, and you would fill it before looking for a Swordfish.

The cell that follows

Look at row 5, column 9. Row 5 has 5, 7 and 9, column 9 has 1, 3, 4, 7, 8 and 9, and the cell’s box has 1, 3, 5, 8 and 9. That leaves 2 and 6. With 2 erased by the Swordfish, row 5, column 9 is a 6.

Row 5, column 6 had 2, 6 and 8. The 2 is gone, and the 6 is now in row 5, column 9, so row 5, column 6 is an 8. From there, filling cells with a single candidate and digits with a single place finishes the grid.

The Swordfish in columns

Swap rows and columns and the same thing holds. HoDoKu says of the X-Wing that if you exchange the terms rows and columns, you get an X-Wing in the columns. In the row view you erase from columns, and in the column view you erase from rows.

In the same grid, look at the rows where 2 can go in each column. Column 2 has rows 4 and 5, column 5 has rows 4 and 8, and column 8 has rows 5 and 8. Each has two places, and together they fit into rows 4, 5 and 8.

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

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

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

The 2s of those three columns use up rows 4, 5 and 8, one each. So you can erase 2 from the other cells of those rows: columns 6 and 7 in row 4, and columns 6 and 9 in row 5. In row 8, the only places for 2 are columns 5 and 8, so there is nothing to erase there.

These are the same four cells as in the row view. In this grid, both views give the same result.

No two of columns 2, 5 and 8 share the same pair of rows, so there is no X-Wing among them. Only all three together fit into three rows.

How to look for one

To look for a Swordfish, pick a digit and list the rows where it has only two or three places. In this grid those are row 2 (columns 7 and 9), row 6 (columns 6 and 7), row 8 (columns 5 and 8) and row 9 (columns 6, 7 and 9).

Then look for three of them whose columns, taken together, come to only three. Rows 2, 6 and 9 fit into columns 6, 7 and 9. Row 8, with columns 5 and 8, does not belong to that group.

Do the same with columns: list the columns where the digit has two or three places, and look for three whose rows come to only three. Even when the shape is there, if the columns you erase from (rows, in the column view) have no other candidates for the digit, nothing is erased. Then try another digit.

The Swordfish depends on correct pencil marks. If you leave out one cell where 2 can go, a row that really spreads over four columns looks as if it fits into three. How to write marks is in How to Write Sudoku Pencil Marks, and an order for checking them is in Stuck on a Sudoku?. A different technique built from three cells with two candidates each is in the XY-Wing 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