XY-Chains in Sudoku

Chain two-candidate cells end to end, and one end must hold the digit both ends share. Every cell that sees both ends loses it.

Home › Blog › XY-Chains

Written by Brian Hamilton and Karan Hamilton.

Brian and Karan are the puzzle lovers and game makers behind Sudoku Online Puzzles. You can learn more on the About page.

Guides are reviewed for clarity, accuracy, and usefulness for solvers. See our editorial standards, puzzle testing process, or send a correction.

Puzzle #65 in our Evil bank starts off reasonably: nine naked singles, nine hidden singles, two pointing pairs, a box-line reduction, three Almost Locked Sets and one round of Simple Colouring. Then it stops. Thirty-five cells are still empty, and none of the eighteen techniques in our Sudoku Helper can find another move.

Sixteen of those empty cells have exactly two candidates. Take the right five in the right order and they prove that one of two cells is a 5. That removes three 5s, and the puzzle gets going again. The five cells form an XY-chain. Everything below uses that board: how the links work, how to find a chain like it, and how often one gets a stuck Evil puzzle moving.

What is an XY-chain in sudoku?

An XY-chain is a line of cells, each with exactly two candidates (bivalue cells), where every cell sees the next one and shares a digit with it. The first and last cells both hold the same digit; call it X. The rule fits in one sentence: one end of the chain must be X, so X can be removed from every cell that sees both ends.

The name describes the cells: each holds two digits, an X and a Y, and the Y of one cell becomes the digit passed to the next. You will also see it written "XY chain". It is the XY-Wing idea stretched over more cells, and the logic stays the same however long the chain gets.

How does each link in an XY-chain work?

An XY-chain alternates two kinds of link. Our diagrams draw them differently, so you can tell them apart without relying on colour:

  • Inside a cell: the strong link (solid line). A bivalue cell must be one of its two digits. If it isn't one, it's the other.
  • Between cells: the weak link (dashed arrow). Two cells that see each other can't both hold the same digit. If one is 3, the other isn't.

Together they work like a relay. You enter a cell on one digit ("this cell isn't 3"), the strong link turns that into the other digit ("so it's 4"), and the weak link hands the 4 on ("so the next cell isn't 4"). Each cell is entered on one candidate and left on the other. If you leave on the digit you came in on, the chain is broken.

Strong and weak, in one line each

A strong link means at least one of the two candidates is true; a weak link means at most one is. A chain that starts and ends with a strong link and alternates in between proves that at least one of its two end candidates is true. XY-chains build that chain out of bivalue cells alone. X-chains and X-cycles build it out of a single digit, using rows, columns and boxes where that digit has only two places.

An XY-chain on 5 in Evil puzzle #65 — before An XY-chain on 5 in Evil puzzle #65 — at the first stall. pattern cells R8C4, R8C9, R5C9, R5C3, R9C3. eliminations in R8C2, R9C4, R9C6. candidates removed: 5 in R8C2; 5 in R9C4; 5 in R9C6. Evil puzzle #65 at its first stall: our helper's eighteen techniques have nothing left, with 35 cells empty. Pencil marks are shown for the 16 two-candidate cells and for the three cells the chain affects. The XY-chain runs through R8C4 {3,5}, R8C9 {3,4}, R5C9 {3,4}, R5C3 {1,3} and R9C3 {1,5}, in that order. Solid green lines join the two candidates inside each cell; dashed blue arrows carry 3, 4, 3 and 1 from cell to cell. Both ends hold 5, so R8C4 or R9C3 is 5, and the struck 5s in R8C2, R9C4 and R9C6, which see both ends, go.. 1 3 2 6 5 9 4 9 7 4 5 8 6 2 7 8 3 9 1 7 1 8 9 1 8 3 4 5 6 2 5 9 4 7 6 3 2 1 8 8 6 1 3 2 3 4 1 3 7 2 1 4 8 6 6 3 7 9 4 2 1 8 5 9 1 4 5 8 3 5 6 2 3 4 2 1 5 3 5 8 1 7 5 7 8 6 9
Evil puzzle #65 at its first stall: our helper's eighteen techniques have nothing left, with 35 cells empty. Pencil marks are shown for the 16 two-candidate cells and for the three cells the chain affects. The XY-chain runs through R8C4 {3,5}, R8C9 {3,4}, R5C9 {3,4}, R5C3 {1,3} and R9C3 {1,5}, in that order. Solid green lines join the two candidates inside each cell; dashed blue arrows carry 3, 4, 3 and 1 from cell to cell. Both ends hold 5, so R8C4 or R9C3 is 5, and the struck 5s in R8C2, R9C4 and R9C6, which see both ends, go.
An XY-chain on 5 in Evil puzzle #65 — after An XY-chain on 5 in Evil puzzle #65 — after the three eliminations, with the naked pair they create. pattern cells R2C6, R9C6. eliminations in R1C6. candidates removed: 8 in R1C6. The same board after the three eliminations: R8C2 is {1,4}, R9C4 {3,8} and R9C6 {7,8}. R9C6 now matches R2C6, a naked pair on 7 and 8 in column 6, so 8 comes out of R1C6, and R1C7 is left as the only place for 8 in row 1. Row 1 and column 6 show all their pencil marks so you can check both steps. From here the eighteen helper techniques finish the puzzle without stalling again.. 1 3 2 1 3 5 6 5 9 1 5 8 4 8 9 4 9 7 4 5 8 6 2 7 8 3 9 1 7 1 8 9 1 8 3 4 5 6 2 5 9 4 7 6 3 2 1 8 8 6 1 3 2 1 5 9 3 4 1 3 7 2 1 4 8 1 5 9 6 6 3 7 9 4 2 1 8 5 9 1 4 8 3 5 6 2 3 4 2 1 5 3 8 1 7 7 8 6 9
The same board after the three eliminations: R8C2 is {1,4}, R9C4 {3,8} and R9C6 {7,8}. R9C6 now matches R2C6, a naked pair on 7 and 8 in column 6, so 8 comes out of R1C6, and R1C7 is left as the only place for 8 in row 1. Row 1 and column 6 show all their pencil marks so you can check both steps. From here the eighteen helper techniques finish the puzzle without stalling again.

The diagram at the first stall shows the chain. Start by supposing R8C4 is not 5:

  1. R8C4 holds {3,5}, so it is 3.
  2. R8C9 shares row 8 with it, so R8C9 is not 3. It holds {3,4}, so it is 4.
  3. R5C9 shares column 9 with R8C9: not 4, so 3.
  4. R5C3 shares row 5 with R5C9: not 3, so 1.
  5. R9C3 shares column 3 with R5C3: not 1, so 5.

If R8C4 isn't 5, then R9C3 is. Either way, one of the two ends is 5. The chain also works backwards: suppose R9C3 isn't 5, and the same five steps in reverse make R8C4 a 5.

Why does the end digit come out of every cell that sees both ends?

One end is 5, so a cell that sees both ends would clash with whichever end turns out to be the 5. R8C4 sits in row 8, column 4 and box 8; R9C3 in row 9, column 3 and box 7. The cells that see both are the three cells of row 8 inside box 7 (R8C1 to R8C3) and the three of row 9 inside box 8 (R9C4 to R9C6). Three of those six still hold 5, so R8C2, R9C4 and R9C6 lose their 5s: the struck marks in the first diagram. In the finished grid it is R9C3, the far end, that holds the 5, but the chain never needs to know which end it is.

The same geometry turns up on every board, so once you have two ends you know where to look:

  • Ends in the same row, column or box: the rest of that house (of both houses, if they share two).
  • Ends in different boxes of the same band or stack, as here: two three-cell segments, each in one end's row (or column) and the other end's box.
  • Ends in different bands and different stacks: only two cells, where each end's row crosses the other end's column.

What the three eliminations unlock

Three 5s doesn't sound like much. The diagram after the eliminations shows why it is enough. R9C6 drops to {7,8}, the same pair R2C6 already had, so column 6 now has a naked pair: 7 and 8 belong to those two cells, and 8 comes out of R1C6. That leaves R1C7 as the only place for 8 in row 1, a hidden single. From there our helper's eighteen techniques solve the rest of the puzzle without stalling again.

Try it on the real board

Open Evil #65 in the Sudoku Helper. Press Next Hint once to fill in the pencil marks, then Next Hint and Apply Hint 25 times. On the 26th press of Next Hint the helper says no logical technique is left and offers a trial-and-error step instead. That is the board in the diagrams, and the chain is waiting to be found.

How do you find an XY-chain by hand?

The logic is short; the hunt is the hard part. This order keeps it manageable:

  1. Get complete pencil marks. A missing candidate can make a cell look bivalue when it isn't, and a chain through it proves nothing. Our pencil marks guide covers keeping them honest.
  2. Mark every two-candidate cell. They are the only cells an XY-chain can use. The Evil #65 stall has 16, and the first diagram shows them all.
  3. Choose X. Pick either a candidate you would like to remove or a digit that appears in several bivalue cells. Start in a bivalue cell that holds X and leave it on its other digit.
  4. Hop. Find a bivalue cell that sees the current one and holds the digit you are carrying. Enter on that digit and leave on the cell's other one. Never reuse a cell.
  5. Stop when you leave on X. Check the cells that see both ends. If none of them holds X, keep going or try another start.

Working backwards is often quicker. Take a candidate you want gone, say the 5 in R9C6. Only two bivalue cells holding 5 see it: R8C4 through box 8 and R9C3 through row 9. If a chain on 5 joins those two, the 5 goes. That leaves a short search between two known cells instead of an open one, and here it finds the five-cell chain.

Mistakes that break a chain

  • Leaving on the digit you came in on. R8C9 is entered on 3, so it must be left on 4. Carrying the 3 on to R5C9 proves nothing.
  • A cell with three candidates in the middle. "Not 3" no longer means "4". That move belongs to a different family (see the last section).
  • Neighbours that don't see each other. Every hop needs a shared row, column or box.
  • Removing X from a cell that sees only one end. The other end might be the X.

Try it: the first diagram also holds a four-cell chain that removes 1 from R6C4. The answer is in the next figure.

A four-cell XY-chain on 1 in Evil puzzle #65 — before A four-cell XY-chain on 1 in Evil puzzle #65 — at the first stall, a shorter chain. pattern cells R3C4, R3C2, R1C1, R6C1. eliminations in R6C4. candidates removed: 1 in R6C4. The same stall, a shorter chain through R3C4 {1,8}, R3C2 {1,8}, R1C1 {1,3} and R6C1 {1,3}, in that order, passing 8, 1 and 3. Both ends hold 1, so R3C4 or R6C1 is 1, and R6C4, which sees both (column 4 and row 6), loses its 1. Row 3 holds 1 only in R3C2 and R3C4, and column 1 only in R1C1 and R6C1, so the same four cells are also an X-chain on 1.. 1 3 2 6 5 9 4 9 7 4 5 8 6 2 7 8 3 9 1 7 1 8 9 1 8 3 4 5 6 2 5 9 4 7 6 3 2 1 8 8 6 1 3 2 3 4 1 3 7 2 1 4 8 6 6 3 7 9 4 2 1 8 5 9 8 3 5 6 2 3 4 2 1 5 1 7 6 9
The same stall, a shorter chain through R3C4 {1,8}, R3C2 {1,8}, R1C1 {1,3} and R6C1 {1,3}, in that order, passing 8, 1 and 3. Both ends hold 1, so R3C4 or R6C1 is 1, and R6C4, which sees both (column 4 and row 6), loses its 1. Row 3 holds 1 only in R3C2 and R3C4, and column 1 only in R1C1 and R6C1, so the same four cells are also an X-chain on 1.

So two techniques reach the same elimination here, and our measurement tried X-chains before XY-chains: in our numbers Evil #65 counts as an X-chain puzzle. The five-cell chain is still the bigger move. It removes three candidates instead of one, and no X-chain on this board removes any of those three 5s.

Is an XY-Wing just a short XY-chain?

Yes. An XY-Wing is an XY-chain of three cells. A pivot {A,B} sees two pincers, {A,C} and {B,C}. Read it as a chain from one pincer: enter on C, leave on A; the pivot takes A and leaves on B; the second pincer takes B and leaves on C. Both ends hold C, so C goes from every cell that sees both pincers, which is exactly the XY-Wing rule.

That has a practical consequence. Our helper already finds XY-Wings, and none of the 808 stalls in our Evil runs had a three-cell chain left. Four-cell chains were rare too: only 3 of the 808 stalls had one, and the Evil #65 stall is one of them. The chains our solver actually used ran from 5 to 11 cells, and 90 of the 107 were 5 to 7 cells long. Once the simpler techniques are exhausted, expect a chain of five cells or more.

How is an XY-chain different from Remote Pairs and a W-Wing?

Remote Pairs is the special case where every cell holds the same pair, say {4,7}. With an even number of cells the chain works for both digits at once: start on 4 and it ends on 4, start on 7 and it ends on 7. So both digits come out of every cell that sees both ends. None of the chains our detector returned at the 808 Evil stalls was a Remote Pair; every one passed through cells with different pairs.

A W-Wing is a close relative, but it is not an XY-chain. Two cells with the same pair {A,B} are joined not by bivalue cells but by a strong link on B: a row, column or box where B has only two places, one seeing each cell. If the first cell isn't A, it's B; so the B-cell of that house that it sees isn't B; so the house's other B-cell is; so the second cell, which sees that one, isn't B and is A. The either/or is the same, but the middle link sits in a house, not in a cell. An XY-chain search won't find a W-Wing, and our helper's W-Wing detector won't find an XY-chain.

PatternMade ofRemovesIn the helper's 18?
XY-WingThree bivalue cells: a pivot and two pincersThe pincers' shared digit, from cells that see both pincersYes
XY-chainBivalue cells, each seeing the next; 5 to 11 of them in the chains our solver usedThe end digit, from cells that see both endsNo
Remote PairsAn even number of bivalue cells, all with the same pairBoth digits, from cells that see both endsNo
W-WingTwo cells with the same pair, joined by a strong link on one digit in a houseThe other digit, from cells that see both cellsYes
X-chainCells holding one digit, linked through houses where it has two placesThat digit, from cells that see both endsOnly the Skyscraper, one four-cell shape

All five are chains of "one or the other" links that differ in what can sit in the middle. "The helper's 18" are the techniques our Sudoku Helper knows. A Remote Pair is an XY-chain, so our XY-chain detector finds those too.

Stuck after XY-Wing and W-Wing? When to look for an XY-chain

Look for one when everything simpler has run dry: in our helper's terms, when all eighteen techniques, from singles up to XY-Wing, W-Wing and Almost Locked Sets, find nothing. To see how much that pays, we took the first 500 puzzles of our Evil bank, applied the helper's eighteen techniques simplest first until they stalled, and then tried four more in a fixed order: BUG, X-chains, XY-chains and forcing chains. The eighteen alone solve 332 of the 500. The other 168 stall at least once, and at the first stall an XY-chain was available on 43 of them, 25.6%.

Techniques allowedEvil puzzles solved (of 500)Gain
The helper's 18332 (66.4%)
+ BUG333+1
+ X-chains347+14
+ XY-chains377 (75.4%)+30
+ forcing chains500 (100%)+123

Each row adds one technique, tried only after everything above it has stalled, in this order. The order matters: a stall that an X-chain breaks first never counts for XY-chains, which is what happened on Evil #65.

XY-chains in 500 Evil puzzles

Available at 25.6% of first stalls (43 of 168). Solved 30 more puzzles than the techniques tried before them (347 to 377), the second-biggest gain of the four, behind only forcing chains. With all four switched on, an XY-chain was the move used 107 times. Across our Evil and Extreme runs we checked every XY-chain elimination the detector produced against the puzzle's known solution: 181,776 checks, and none was wrong.

On our Extreme puzzles they do nothing. The eighteen solve one of the first 500; the other 499 stall at the starting position, before a single digit is placed, with 57.5 empty cells and only 0.6 two-candidate cells on average. An XY-chain is made of two-candidate cells, and those boards have almost none. None of the four techniques we tested moves them.

What XY-chains don't cover

  • Only two-candidate cells. A chain that runs through a cell with three candidates, or through a strong link in a house as a W-Wing does, is a general alternating inference chain (AIC). Those find more, and we didn't build or count them. Every number above is for chains made only of bivalue cells.
  • Open chains only. When the two ends see each other, the chain closes into a loop, which can remove more than the end digit. We counted only the end-digit eliminations.
  • Not every stall. At three first stalls in four there was no XY-chain at all.

When there's no chain, the next step in our runs was a forcing chain: assume a digit, follow the singles, and see what breaks. Forcing chains cleared every remaining Evil stall, but 397 of their 603 moves were the contradiction kind (assume a digit and find a clash), which is close to trial and error. That is why we try XY-chains first. For where all of these sit among the other techniques, see our sudoku techniques guide.