SudokuWiki.org
Strategies for Popular Number Puzzles

# X-Cycles

X-Cycles are the start of a large family of 'chaining strategies' which are fundamental to solving the harder Sudoku puzzles. X-Cycles are strongly related to Simple Coloring.

A 'chain' is a series of links hopping from one candidate to another following very simple rules. A candidate can either be ON or OFF. That is, we either think it is a possible solution to that cell, or we do not. There are consequences to the rest of the board when we 'link' these two states.

In the X-Wing structure in Figure 1, as an example, we can consider B3 to be OFF. This forces the the 9 in B8 to be ON since it's the only remaining 9 in the row. If B8 is ON then that removes the 9 in H8. Again, the consequence is to turn ON the 9 in H3 - and that closes the loop by confirming the 9 in B3 is OFF.

In this X-Wing example three things are apparent. I went round clock-wise, but I could easily make the same logical chain going round from B3 to H3 to H8 to B8 and back to B3. Also, could decide that the start cell was ON and follow the loop round. And lastly, B3 is arbitrary, I could start on any of those four cells.
Another important way of thinking about this situation is from the point of view of the links. When a candidate is turned OFF AND there are only two candidates in the unit, then we can create a Strong link, as between B3 and B8 (marked in a thick blue line) and H8 and H3. Because there are just two 9s in each row, we know that if one is not a 9, the other must be. A strong link is where:
!A => B (if not A, then B)

A => !B (if A, then not B)

Strong and Weak links alternate just as candidates are turned OFF and ON. When we turn a candidate X ON we effectively remove ALL other candidates of X in ALL other units. However, when we turn a candidate X OFF it has no effect unless the unit has only two of X in it.

A "Cycle", as the name implies, is a loop or joined-up chain of single digits with alternating strong and weak links, as the X-Wing in Figure 1 shows.

In Figure 2, we have a 2-2-2-formation Swordfish re-drawn to show the strong and weak links. The loop characterises the X-Cycle, and the strong/weak links alternate.
Nice Loops have evolved a notation which is useful when accompanying a diagram or as part of an explanation. X is, of course, the digit, and we use the row letter and column number notation to identify cells (e.g., B2, F8). The cells in the loop are linked with a minus to indicated X has been turned OFF, and a + to indicated X has been turned ON - you will see these colours on the solver. An example:

+x[cell 1]-x[cell 2]+x[cell 3]-x[cell 4]

The 2-2-2 Swordfish above can be expressed as:

+4[B2]-4[B4]+4[H4]-4[H8]+4[F8]-4[F2]

The only thing not explicit in this notation is that the last cell joins back onto the first cell. Thus, 4[F2]+[B2].
Loops can be of any length but they don't re-use any candidate.

Chains like these that go in a loop are called Continuous. They have three characteristics:
• Firstly, it doesn't matter which way you walk round the loop - clockwise or anti-clockwise
• Thirdly, each cell could be ON or OFF - as long as you alternate.

Even with the convention of starting with the top left-most cell, there are four ways we could write down a chain:
• Clockwise with B2 ON +4[B2]-4[B4]+4[H4]-4[H8]+4[F8]-4[F2]
• Clockwise with B2 OFF -4[B2]+4[B4]-4[H4]+4[H8]-4[F8]+4[F2]
• Anti-clockwise with B2 ON +4[B2]-4[F2]+4[F8]-4[H8]+4[H4]-4[B4]
• Anti-clockwise with B2 OFF -4[B2]+4[F2]-4[F8]+4[H8]-4[H4]+4[B4]

I've deliberately used neutral colours in the diagram above (yellow and blue) not to given the impression there only one way to write the same chain. However, the solver will return very positive red and green highlighting but that's because it has discovered one of those four ways first and discarded the other three identical ways.

In this example of an 8-Cycle in Figure 3, I have split the two possible states into two diagrams.

This shows how each pair of strong links (that have only two candidates in the shared unit) can be set overall. No other combination of ONor OFF is possible.

The notation can either be, left
+8[B3]-8[B4]+8[C6]-8[D6]+8[F5]-8[F3]+8[B3]
or right
-8[B3]+8[B4]-8[C6]+8[D6]-8[F5]+8[F3]-8[B3]

The yellow cells are units where other 8s can be eliminated, which in this case correspond to the third column and boxes 2 and 5 because that's where the weak links are located. C4 is eliminated because of either B4 or C6

## Nice Loops Rule 1

Nice Loops that alternate all the way round are said to be 'continuous', and they must have an even number of nodes. With a continuous X-Cycle, candidates are not removed from the loop since the loop does not have any flaws. Instead we are looking to eliminate on the units that can be seen by two or more cells that belong to the loop.

Figure 4 is a real-life example of an X-Cycle based on 8. The cells with links are in red and green. We can immediately see that C2/C7 is a weak link across the row because of the 8 in C3. G2/H3 is also a weak across the box because of the third 8 in G3. The last weak link is in box 9, J7/H9. Any other 8s in these units can be removed, which makes it a powerful technique. We end up with a loop containing only strong links – a result identical to a Colouring (Singles Chains) solution.

The output from the solver will contain the following information:

X-CYCLE (Alternating Inference Chain):
+8[C2]-8[C7]+8[J7]-8[H9]+8[H3]-8[G2]+8[C2]
- Off-chain candidate 8 taken off C3 - weak link: C2 to C7
- Off-chain candidate 8 taken off C9 - weak link: C2 to C7
- Off-chain candidate 8 taken off G9 - weak link: J7 to H9
- Off-chain candidate 8 taken off G3 - weak link: H3 to G2

In summary we can see that

• X-Wing is a Continuous X-Cycle with the length of four.
• Swordfish of the 2-2-2 formation is a Continuous X-Cycle with the length of six.

Although there are many other parallels as well.

 Go back to Remote Pairs Continue to X-Cycles (Part 2)

## ... by: Zaphod

Sunday 3-Sep-2023
Hi,

Perhaps add a comment and a link to the x cycles part 2 page covering discontinuous links. Otherwise it relies on a reader figurung outh there is something else (which took me a while).

## ... by: Gere

Monday 2-Jan-2023
Hello
Andrew Stuart writes:
Yes in short.
Which I hope will set everything straight regards the two types of link
- [Del]

## ... by: Ed Logg

Friday 9-Oct-2020
Your x-cycle code seems to miss some cases:
..3...9.11967..5.....19..6....479613.19...7.83.78.129..71945..6..5.871.99..61....
proceed until you get to the xy-chain. Notice you missed the x-cycle case 3 with 5 at E8 F9 F5 E4 A4 A5 that eliminating the 5 at F5, I suspect that is because you took the branch at F9 to J9 and J8 without going back and trying the F9-E8 strong link.
Andrew Stuart writes:
Here is a link to your puzzle. But I can't see the X-Cycle. - [Del]

## ... by: Asday

Tuesday 11-Aug-2020
What about discontinuous cycles? I don't understand the solver's output for:

41_5__6_3
8_____541
3___147_2
6_17_5_38
2__4_197_
7______1_
1732__8__
_2_17_3__
___3__127

X-Cycle
X-CYCLE on 9 (Discontinuous Alternating Nice Loop, length 8):
-9[A8]+9[C8]-9[C3]+9[F3]-9[D2]+9[D5]-9[A5]+9[A8]
- Contradiction: When 9 is removed from A8 the chain implies it must be 9 - other candidates 8 can be removed

## ... by: Jim

Friday 5-Jun-2020
Hi Andrew,
You have a great site - I have learned a lot. It seems to me there is a slight bug in one of the Simple Coloring examples (the one with 2...41..6 in row A). After the 4th SC there is an X-Cycle, but the link from E9 to F8 is a strong link, not a weak link as shown. So it isn't a true X-cycle with 3 strong links in a row, or am I missing something? The puzzle solves OK, and if you remove the X-Cycle check box, the puzzle also solves using an XY-Chain.

Thought you would want to know.

Best
Andrew Stuart writes:
Can't find this, the example only has one X-Cycle. - [Del]

## ... by: Jim

Wednesday 12-Jun-2019
Hi Andrew, I can get my head around most of the logic of your excellent illustrations of "x cycles" except how to select either a +(x) or -(x) candidate in the start cell of a Discontinuous Alternating Nice Loop. If you select (-x) to start you end with +(x) and the contradiction that (x) cannot be (-) and other candidates must be removed from the start cell. The opposite is true if you start if you start with (+x) and with the contradiction that (x) cannot be (+) and must be removed. Clearly one or other is the solution but how do you decide which to opt for.

Keep up the excellent work, your illustrations are second to none

## ... by: Arno

Monday 4-Feb-2019
Hi Andrew,

Near Fig.1 example, you wrote "Also, could decide that the start cell was ON and follow the loop round." But, in this case (startcell B3 ON), then B8 is off, but it will not mean that H8 is ON (B8-H8is weak link), so chain is not built.
I think that you can't go any direction (cw ot ccw) with both states (ON/OFF) on start cell:
If start cell is OFF, it must go thru a strong link; and if start cell is ON, then the first move should be thru a weak link.
If you agree with this, the 4th paragraph near fig.1 should have more restrictions, since it's little confusing.

## ... by: Justin

Thursday 24-Jan-2019
Hi, in your explanation of x-cycles you show an illustration using an 8 x-cycle, labelled Figure 3. I am still learning these techniques but if, as you say, this strategy elimates candidates that can be seen by 2 or more cells in the loop why in figure 3 is the 8 in C2 also not eliminated, please? It can see b3 and c6. Is it that it is not enough merely to see 2 cells in the loop, is it also necessary for the candidate we are looking to eliminate to be in the same unit as the cells it can see in the loop?
Sorry if this is a sill question. I really enjoy studying these strategies and consider your site to be excellent. I have spent many hours on it and have recommended it to friends, who are similarly impressed with it.
Andrew Stuart writes:
This example is about off-chain eliminations. There are no eliminations on strong links because those units already have the minimum 2 candidates. Weak links have three or more. Since the loop identifies two of the set that must be true (on or the other) the remainder are redundant. But they must exist in the unit the ends of the link share. C2 may be seen by B3 and C6 but we can't be sure B4 and C6 are solutions. The opposite candidates may be true, eg B4 and D6. Nice Loop Rule 1 works on the adjacent cells and the unit they share.

I have re-drawn Figure 3 and added some more text, to be more clear.
- [Del]

## ... by: britanico

Sunday 16-Dec-2018
Dear Sir
Refering fig. 2 :nice loop on 4 it seems to me you can't start B2 OFF clockwise as you have a weak link to B4, that must start with ON state to provide any inference.Only if there's a strong link can then B2 start with a OFF state, clockwise.
Andrew Stuart writes:
This is correct, but you can start OFF on B2 if you go south to F2. Not every direction and every state will work, it is sufficient that one state does. - [Del]

## ... by: Kavala

Monday 29-May-2017
This from puzzle 27th May 2017.
X-Cycle
X-CYCLE on 2 (Discontinuous Alternating Nice Loop, length 6):
+2[C7]-2[C5]+2[E5]-2[E8]+2[F7]-2[C7]
- Contradiction: When C7 is set to 2 the chain implies it cannot be 2 - it can be removed
I follow this but I see only five links and five nodes. Except you count the start and end nodes, which are the same, as two nodes ?
Andrew Stuart writes:
Some notators don't bother to but I choose to to make the closure of the loop explicit. - [Del]

## ... by: Ian

Friday 22-Apr-2016
I don't understand how you selected the 8s to begin with, and which ones to link to. Further explanation would be useful.
Andrew Stuart writes:
I usually start by looking for the Strong Links - You can find them on the solver by ticking the Strong Links under the strategies list. They have just two 8s in the row, column or box - [Del]

## ... by: Bob Rodes

Tuesday 15-Mar-2016
I think there's an error here in Fig. 1, (and so also with your X-wing article which uses the same diagram). If B8 is on, that removes the 9's in BOTH H8 and F8. The consequence is to turn both F3 and H3 on, which is a contradiction.
Andrew Stuart writes:
That would be true if all the 9s where known and plotted but I have placed just a few to illustrate a chain. But I've added another 9 in F1 to confound your point - which is better as its more realistic - [Del]

## ... by: Mike Van Emmerik

Sunday 6-Sep-2015
I can answer part of my own question in my last post: the second X-cycle in the third X-cycle exemplar is not a straight simple-colouring problem.

However, it seems to me that it can be solved with a simple extension of the simple-colouring technique. If you start on a particular square and end up on that same square at the end of a strong link (with an odd square count, starting as I do with zero), then it seems to me you have a Discontinuous Alternating Nice Loop situation, and the candidate in question (in this case, an 8) must be the solution, so other candidates in the start/end cell (in this case, one candidate, a 6) can be eliminated. I'll grant you that this is enough different from simple colouring to warrant a separate name.

I maintain however that all the other situations where the X-cycle has found the "first" solution, should have been found by the simple colouring solver.

I also note that simple colouring can be extended to grouped simple colouring, so the same comments apply to the grouped X-cycles. As a result, I don't believe that grouped X-cycles deserve to be in the "extreme" strategy category.

I'm guessing that the naÃ¯ve belief that a small group of general strategies (like simple colouring) can solve almost all Sudoku problems happens to most beginners like me :-O

## ... by: snaponit

Friday 25-Jan-2013
I second this question:

MONDAY 26-NOV-2012
... by: Hilary
Your site is very helpful. The main problem I have with the puzzles that require diabolical strategies is that I don't know how to pick 'x' for the x-cycle for example. So I usually pick 'x' at random. But to me, that's trial and error and I was wondering if you had suggestions for a systematic approach

Thanks !
Andrew Stuart writes:
That's true, it isn’t always obvious where to start looking and sometimes it jumps out. I'd go for numbers that are thin on the ground. The solver can highlight individual numbers which makes it clearer how to spot the two-per-unit links you need. - [Del]

## ... by: Hilary

Monday 26-Nov-2012
Your site is very helpful. The main problem I have with the puzzles that require diabolical strategies is that I don't know how to pick 'x' for the x-cycle for example. So I usually pick 'x' at random. But to me, that's trial and error and I was wondering if you had suggestions for a systematic approach

Thanks !

## ... by: Cathy

Monday 27-Feb-2012
Figure 1 is missing from your article (the url in the page's source ends in .jpg, but the actual image ends with .png)
Andrew Stuart writes:
Try refreshing your cache or hitting F5 a few times. I've replaced a great number of GIF/JPG image files with PNG. Some are so old they are heavily cached by the server and intermediate servers and probably your browser. I can see requests for the old files in the logs but I am pretty sure all the new images are in place. - [Del]

## ... by: JimS

Friday 31-Dec-2010
Laura,

Maybe Andrew answered your question privately or maybe it is posted somewhere else on this site but I thought that I would try to answer your question.

As you follow a continuous, alternating nice loop along the path some of the weak links can actually be strong links -- they just don't have any digits that can be eliminated. Imagine an X Wing which only has digits that can be eliminated in one unit not two.

Andrew might be more accurate if he said "weak or strong links" instead of just "weak links" but that would be cumbersome and wouldn't really help the understanding of the concepts.

Hope this helps.

## ... by: Laura

Friday 12-Feb-2010
I thought only strong links could have weak interference - not the other way around. I have come across several puzzles in which your solver showed a weak link and it should have been strong- there were only 2 of that number in the square. Is there a special circumstance where this could happen? Please advise thanks

## ... by: ECC

Saturday 11-Apr-2009
The missing detail in the explanation is that any odd length sequence of strong links counts as a single strong link, except that it cannot close the loop. That is, two consecutive strong links in a loop gives you an answer as described under discontinuous loops, but four does not.

## ... by: Elleda Katan

Sunday 5-Apr-2009
I'm finding again a problem I have encountered before : what seems like a contradiction between your explanation here and how x-cycles are 'used' in some of the daily puzzles. I'll use 4/5 [todays] as my example but I hit the same problem in 2/28 & elsewhere.
[1] In none of the x-cycle demos is the digit removed from the cells forming the loop. Instead it is eliminated " from cells that can be seen by two or more [loop] cells." In the 4/5 puzzle 7 is eliminated from E1, the beginning and end of the loop.
[2] The end result says your explanation is a loop containing strong links. However, in 4/5, eliminating 7 from E1 destroys the loop.
[3] In the documentation under the 4/5 puzzle, the loop is described as : 7[E1]-7[E4]=7[J4]-7[J3]=7[G1]-7[E1] "Discontinuity is two weak links joined……" However, 7[G1] to 7[E1] is a strong link, not a weak one, no? Shouldn't it read : 7[G1]=7[E1]?
Please I love love love your puzzles and am trying to get smarter at understanding the more advanced strategies, but this confusion has me X-ing out x-cycles from solutions because I am so baffled by them. Thank you for your time.