SudokuWiki
SudokuWiki.org
Strategies for Popular Number Puzzles

Y-Wing Strategy

Y-Wing Figure 1
Y-Wing Figure 1
This is an excellent candidate eliminator. The name derives from the fact that it looks like an X-Wing - but with three corners, not four. The fourth corner is where the candidate can be removed but it leads us to much more as we'll see in a minute.

Lets look at Figure 1 for the theory.

A, B and C are three different candidate numbers in a rectangular formation. Three of the corners have two candidates AC, AB and BC. The cell marked AB is the key. If the solution to that cell turns out to be A then C will definitely occur in the lower left corner.If AB turns out to be B then C is certain to occur in the top right corner. C is a complementary pair.
Y-Wing Figure 2
Y-Wing Figure 2
So whatever happens, C is certain in one of those two cells marked C. The red C can be 'seen' by both Cs - the cell is a confluence of both BC and AC.
It's impossible for a C to live there and it can be removed.

In Figure 2 I'm demonstrating the sphere of influence two example cells have, marked red and blue. X can 'see' all the red cells, Z can 'see' all the blue ones. In this case there are two cells which overlap and these are 'seen' by both.
Y-Wing Figure 3
Y-Wing Figure 3
If our A, B and C are aligned more closely they can 'see' a great deal more cells than just the corner of the rectangle they make. In Figure 3 BC can see AB because they share the same box. AC can see AB because they share the same row. BC and AC can see all the cells marked with a red C where this Y-Wing can eliminate whatever number C is.
Y-Wing Example 1
Y-Wing Example 1 : Load Example or : From the Start

I have found a superb 'tough' Sudoku puzzle with a sequence of five Y-Wings and this illustrates the full range of this strategy. The first three are pictured here but you can load the puzzle into the solver to see the remaining examples.

The first Y-Wing finds the AB cell in A2 which links 8 with the pair on B3 and the 3 in J2. Common to both the pincer cells is 4 which must go in either B3 or J2 so 4 in H3 can be removed.
Y-Wing Example 2
Y-Wing Example 2 : Load Example or : From the Start

The second Y-Wing gets two candidates because of the alignment in column 1. The 8s in B1 and C1 can both see the cells A2 and G1 which also contain 8. These pincer cells are linked to the pair [4,3] in J2.
Y-Wing Example 3
Y-Wing Example 3 : Load Example or : From the Start

The third step is included because it shows a very neat rectangular alignment which almost mirrors the theory diagram. You couldn't ask for a clearer example. 4 must go in B1 or D6 otherwise 7 and 8 would be used up and there'd be nothing to go in B6. The 4 in D1 is the lone candidate that can see the yellow cells and should be removed.

Y-Wing Exemplars

These puzzles require the Y-Wing strategy at some point but are otherwise trivial.
They also require one Naked Pair.
They make good practice puzzles.



Comments

Comments
Talk

... by: Tom

Sunday 28-Jan-2024
Question: In Example 3 why can't the 8s in A6 and D6 de eliminated?
REPLY TO THIS POST

... by: Robert

Sunday 10-Dec-2023
It occurs to me that sometimes a "bent" set could actually be straight.

Take for example the Y-wing Figure 3. Suppose the "BC" were instead on the top row, either just to the right or just to the left of the cell with "AC". All of the eliminations would still work. Those on the top row would now be possible by a "locked set" strategy, since the three cells with "AB", "BC", and "AC" only have three values between them. But the three eliminations along the bottom row do not follow so easily.

In all cases, though, either "bent" or a "straight" extended version, it seems the Y-wing is a special case of an AIC.
REPLY TO THIS POST

... by: Hello!

Saturday 24-Jun-2023
@Cotswold Mike I can help you.I have been making a program lately !
REPLY TO THIS POST

... by: m.naser ( Mohammad Naser masalehgoo)

Thursday 16-Mar-2023
Hi,
This is (m.naser) from Iran. I introduce a new solution to the Sudoku puzzles by introducing (Ywing 22 , Ywing 2x , hidden Ywing). It is appropriate to introduce this solution to the world of Sudoku .
Often It has happened that you identify a (ywing pattern), Which is unsuccessful. it means you can not able to eliminate any candidate. I named this pattern as (ywing22).
Can you help me to register this strategy?
Sincerely yours
m.naser
REPLY TO THIS POST

... by: Bonnie

Friday 24-Feb-2023
I don’t understand how to pick the pivot. It seems like any of the three cells could be pivot to the others. I’m just not seeing it. Help?
REPLY TO THIS POST

... by: Bam

Monday 2-Jan-2023
Please fix your cell labeling!
It is customary to label columns with letters, and rows with numbers — Your Otherwise excellent article incorrectly reverses this industry standard practice (And also contains a few minor typographical errors, as well).
I hope you’ll find a competent proofreader and/or reviewer, next time.
Andrew Stuart writes:
These pages have been up for many years and people still find typos. I've made hundreds of minor corrections thanks for eagle eyed readers. It's surprisingly hard to vet one's own writing. But do let me know specifically so I can kick myself.

Regards the coordinate system you're the first to every suggest they are the wrong way round. I was building the solver five months after the first ever Sudoku was published, which was about 2005. Even then there was a large active forum community and I followed their conventions. Of course it was all new ground, so names and things were constantly being invented and then adopted more widely. A big minority wrote/preferred the rXcY system but most people, including me, preferred the shorter letter+number. At no point did I see a board with letters for columns. Which industry is it standard? Chess?
- [Del]
Add to this Thread

... by: Bentimus

Wednesday 17-Nov-2021
I love your explanation. It's a lot clearer than others out there.

Now that I get it, I have a question: Can a single Y-Wing be exploited three ways, every time?

In example 1, your illustration uses A2 as the AB Cell to remove 4 from H3. Can you also use I2 as the AB Cell and remove 8 from B1,C1,A3,C3? And then again with B3 to remove 3 from row 2? (Row 2 doesn't actually give us new information, but I hope you know what I mean)

If that is the case, example 3 would remove these:
4 from D1
8 from A5,C5
7 from row B, but there aren't any left
REPLY TO THIS POST

... by: Beginner

Tuesday 8-Jun-2021
This is a great program.
Step by step, it works thru the puzzle and helps me learn.
I appreciate the learning.
BUT, the hard puzzles -
I do NOT understand the logic - I see the results
I just don't see the logic to get there
Thanks for the program - It really helps.
REPLY TO THIS POST

... by: dan

Saturday 27-Oct-2018
I'm trying to learn the Y-wing. I get most of it, but I also see other candidates in the area that you don't eliminate, and I'm not sure why. In example 1, why not eliminate the other 4s in column 3? You only eliminated 1 of the 4s
REPLY TO THIS POST

... by: Cotswold Mike

Tuesday 13-Feb-2018
I am developing a home grown progran (using Ada). It fails to recognise the Y-Wing in example 3 (see above) because, prior to reaching that point, it has failed to reduce the candidate list of B1 from to (4,7,8) to (4,7). By visual inspection I can see why this reduction should be so in this individual example, but I cannot recognise or formulate an appropriate general case algorithm to include in my source code. Any suggestions will be most welcome.
REPLY TO THIS POST

... by: David Raymond

Sunday 2-Apr-2017
The puzzle from the Mepham Group on 3/31/17 had an interesting combination that I stumbled across a solution for, and wondered whether it has been identified previously. A potential Y-Wing had an extra unrelated candidate in one of the pincer cells. I imagined that this candidate did not exist and the consequence of this was that the Y-Wing eliminated a candidate in the intersection cell leaving only one other candidate which was identical to the unrelated candidate that I had theoretically eliminated. Since I could conclude that this candidate was in one of two cells, it could not exist in any other cells common to those two. This led to a quick solution of the entire puzzle.
The great feature of Y-Wings is that they can be seen quickly in puzzles worked by hand with pencil marks as opposed to chain solutions.
REPLY TO THIS POST

... by: David Spector

Wednesday 20-Jul-2016
If you ever want to allow the user to set up any techniques, list the techniques in an "available for use" column, and allow drag-and-drop to move desired techniques into a second "active" column, where they will be used by the solver. Then not only the subset of techniques can be specified, but also the order.

There could also be ways (lines and arrows or just checkboxes) to indicate how groups of techniques are to be repeated (interatively or nested).

Just for completeness...
Andrew Stuart writes:
Yes, I'd like to add the ability for the user to re-order the strategies. I've done my best to find a practical order that is also attempting to order by complexity. This is hard since some are sub-sets and some overlap. You can remove strategies by unticking. Re-ordering will require quite a complex user interface which is already daunting to some users. But it is something I'd like to do. - [Del]
Add to this Thread

... by: Yoshihiro Sato

Friday 16-Oct-2015
Your web page is very interesting to me.
I am learning Y-Wing strategy from this page.

In Y-Wing Example 3, I find two Y-Wing candidates.

In address of { {B, 6}, {B, 1},{D, 6} }, Y-Wing is { {3, 4}, {3, 8}, {4, 8} }, then 4 in {D, 1} shoud be removed. This is shown in your figure.

In address of { {H, 4}, {H, 3}, {F, 4} }, Y-Wing is { {3, 4}, {3, 8}, {4, 8} }, then 8 in {F,3} shoud be removed. Is this correct or wrong ?

Best regards, Y.Sato
Andrew Stuart writes:
Yes this is correct. I see that my example puzzle doesn't get 5 Y-Wings anymore, due to changes in the solver. So I will look for another example to illustrate this strategy - [Del]
Add to this Thread

... by: Jakesprake

Saturday 22-Aug-2015
Has the 47 in Es any bearing on it?
REPLY TO THIS POST

... by: zoph

Sunday 25-Jan-2015
I was hoping to use your Y-wing exemplar 4 for practice in recognizing Y-wings. I was disappointed to find I could solve entire puzzle using only your "getting started" simple strategies.

I presume Exemplar 4 is the hardest of the four exemplars, owing to it highest score of 179.
Andrew Stuart writes:
I'd be interested to know the steps you took at that bottleneck. While there's a great many possible paths I'm certain the bottleneck exists, but I can't human duplicate intuition I guess - [Del]
Add to this Thread

... by: Cotswold Mike

Thursday 11-Dec-2014
Many thanks for your lucid description of Y_Wing. At last I believe I understand it. My home grown program (written in Ada) now recognizes a Y_Wing and exploits it. There are a couple of "false Y_Wing" situations to be ironed and I am reasonably confident that they can be cracked.
REPLY TO THIS POST

... by: georgemiller

Wednesday 7-May-2014
in example one above, why can't cell J2 be the AB cell with cells A2 and B3 functioning as the BC and AC cells of the Y wing? If so, then all the eights could be eliminated in Box one
except of course the eights in cell A2 and A3.
REPLY TO THIS POST

... by: Jon

Wednesday 12-Mar-2014
Great explanation of the Y-Wing. Even a novice dummy like me could grasp it. But,,,, possibly by accident,,,, when I printed it,,,,,, from the start,,,, I only needed one y-wing to solve it,,, not 5... Once I went through all the "easier" steps,, I got to the y-wing you show in Example 1 and went on to solve it with no other y-wings... Did I get lucky and make a mistake along the way??
Andrew Stuart writes:
I may have to replace that example, the solve only finds two now. I think that is due to changes in how the solver has evolved over time.
And there are many minor variations on the solving path you can take, so yes, your solution might only get the one, depending on what you did and how much intuition you used.
- [Del]
Add to this Thread

... by: dano

Monday 8-Apr-2013
I came across a pattern that is similar to what you list. The alignment of the pattern was

68 - 89 aligned in a row (h1 - h7)
89 - 69 aligned in the same box (h7 - I8)

If this is a y-wing then the complementary pair are the 9's.
Is this a valid y wing and if so can you eliminate all the other 9's from the box that contains the 89-69 complementary pair?
ralph maier replies:Saturday 24-Aug-2013
@ DANO
As for your ex if you think in terms ABC it is obvious that the 6 will be the C cell not 9 so you can eliminate the 6S that see the 2 cells containing the 6s
Add to this Thread

... by: S. Lee

Friday 28-Dec-2012
While testing my own solving algorithm with your fascinating 5-fold Y-wing example, I was surprised since my solver just required 2-fold exploitation of Y-wing strategy as follows:

Step #23 : Y-Wing (<--- This coincides with your first Y-wing step)
{3,8}[A2] hinges {4,8}[B3] and {3,4}[J2]
-> 4 taken from H3

Step #24 : Y-Wing
{3,8}[H3] hinges {4,8}[H7] and {3,4}[J2]
-> 4 taken from J7
-> 4 taken from J8

This is the only step that the puzzle required except for Naked Single, Hidden Single and Intersection Lock (=Pointing Pair + Box/Line Reduction).

It is an interesting phenomenon for me that the total number of advanced strategies is largely affected by the way how we realize the strategy into algorithm.
Andrew Stuart writes:
You're correct, a different search order will find different instances of the same strategy and potentially a more optimal solve path. Currently the solver only returns the first instance it finds and it's been a big ambition of mine to allow the user to dismiss one and use the next but it would greatly complicate the UI. What we're both after is a fully branching solver that explores all eliminations. That's not to hard offline with lots of memory and time and something I want to explore as well - [Del]
Add to this Thread

... by: Mike Kerstetter

Wednesday 21-Nov-2012
I understand the Y-wing concept thanks to your excellent explanation. My problem is seeing/finding them in the puzzle. The don't "stand out" for me. Are there any insights you can offer that might help me recognize that a Y-wing might be lurking around and how to track it down?
REPLY TO THIS POST

... by: SpearheadJams

Tuesday 16-Oct-2012
I am impressed by the work that you have done on this site. Much respect to you and your team. At the end of the day perfection is simple/elegant...
REPLY TO THIS POST

... by: Dino Hsu

Monday 1-Oct-2012
Hi Andrew and all,

There's a small mistake about Y-wing in the logic of proof:

I'd like to use the Y-Wing Fig. 1 to explain this.
I will use coordinates for the cells:
Cell B2 with AB (bi-value), the pivot, which connects (sees) B5 and E2
Cell B5 with BC (bi-value)
Cell E2 with AC (bi-value)
Cell E5, the target cell to eliminate C, if any, which "sees" both B5 and E2

The definition of "see" is "two cells within the same element (row, column, box)" (the two cells see each other)

The statement "So whatever happens, C is certain in one of those two cells marked C.", which implies C in one of the two cells, actually C can also be in both cells.

Note that: the two B's in cells B2 & B5 are not a "locked pair", in other words, there could be other B's in row B. Similarly, the two A's in cells B2 & E2 are not a "locked pair" either, there could be other A's in column 2. As a result, (B5, E2) could be (C, non-C), (non-C), or (C, C), and in all scenarios, C should be eliminated from cell E5.

I find this mistake (saying the above A, B should be "locked pairs") in the book "Extreme Sudoku for Dummies" by Andrew Heron & Andrew Stuart, so I check here, I hope this helps the discussion to go clear.

Thanks for your attention.
Andrew Stuart writes:
It is true that there may be other As, Bs and Cs in any of the rows, columns and boxes to which the marked A, B and C belong. But that is not relevant to the argument - hence the first basic diagram does not need to include them. The reason we don't care about other As or Bs elsewhere is that we are only turning a candidate ON (in B2), ie an argument based on "if a cell contains A then ALL other cells it can see must have A removed". We apply this twice to the pivot cell containing A and B.
If B2 contains A then E2 does not contain A - and being a bi-value cell, it will be C
If B2 contains B then B5 does not contain B - and being a bi-value cell, it will be C
The Y-Wing strategy tells us nothing about the ultimate solution of B2, B5 or E2 (it is not designed to) - and yes it is possible for C to be in both B5 and E2 - which just goes to reinforce the idea that E5 can't be C!
- [Del]
Add to this Thread

... by: Hans

Tuesday 28-Jun-2011
Hallo Andrew,

Thanks for excellent explaining - although I got an other question.

y-wing explanations, figure 5, left side:
between green marked cells 18 and 15 there is the cell 12578 which contains also an 8. Why is this 8 not deleted?
Andrew Stuart writes:
Because that cell can't be "seen" by all the green ringed cells., only by two of them. - [Del]
Add to this Thread

... by: senselocke

Sunday 17-Apr-2011
Thank you so much for the write-up, and the site as a whole.

Doing the step-by-step solving, with explicit reasons and links to the techniques, is exactly what I needed to be a better puzzler. Thank you so much!
REPLY TO THIS POST

... by: zoph

Friday 15-Apr-2011
I appreciate this Y-wing method/logic and follow the logic through your Figure 4 but Figure 5 baffles me.

I fail to understand the logic underlying one cell seeing another. Is it possible to easily explain the eliminations shown for Figure 5 without using the "seeing" concept.

Regarding Figure 5, and the "seeing" concept, could you explain exactly which cells see which other cells, why they do; and why some cells do not see other cells and why.

Thank you for your great site and your kind and patient instruction.
Andrew Stuart writes:
"Seeing" means a cell shares the same row or same column or same box (sometimes a combination of these) - [Del]
Add to this Thread

... by: nihal

Tuesday 26-Oct-2010
really good example. fantastic site.
REPLY TO THIS POST

... by: Helen

Friday 17-Sep-2010
Am I correct in assuming that finding a y-wing does not mean that the three cells forming the y-wing necessarily have to have those three numbers in the solution. It is only an eliminating strategy/
REPLY TO THIS POST

... by: Reggie

Thursday 10-Jun-2010
With the techniques in your "Logic of Sudoku" book, I am only able to solve up to level 5 in Dr. Arto Inkala AI Escargot book. Level 6 to 10 make me feel like I know nothing about sudoku

Do you have another more advanced book? Where in the world can I learn strategies that will let me crack those Arto Inkala puzzles?
REPLY TO THIS POST

... by: Vidyasagar

Friday 26-Feb-2010
I have not seen such lucid explanation of XY wing as you have done. The reasoing given by you makes one understand this difficult concept.
thanks
REPLY TO THIS POST

... by: Ed Wieder

Saturday 30-Jan-2010
The Y-Wing explaination is very good. It can be improved on by being consistent in numbering examples and figures. It might also be mentioned that the Y-Wing can only be used when one of the canidates is not in the same 3X3 box where the other two are located.
Andrew Stuart writes:
Good point. - [Del]
Add to this Thread

... by: Jody

Tuesday 12-Jan-2010
The image of the pincer really brought the Y-wing concept into focus.
REPLY TO THIS POST

... by: William Balzar

Monday 11-Jan-2010
Just learned the "Y-Wing" from your site.... WOW how elegant!!! I am like blown away. I will soon order that book. The best part of all of this is that there is still more to learn!!!! Like in that "Wayne's World" Movie: I am not worthy!!!

Bill (NOT over the hill and just 5 months from 65)

THANKS
REPLY TO THIS POST

... by: John

Saturday 2-Jan-2010
Nice work! I now can understand the Y-wing concept. Thanks for taking the time to teach those of us with lesser skills.
REPLY TO THIS POST

... by: John Myfrianthousis

Tuesday 29-Dec-2009
Brilliant! I am a medium-advanced player who often falls after a specific point. I believe now = especially with y-wing one I will recognize this formation
REPLY TO THIS POST

... by: ChandaMija

Thursday 17-Dec-2009
I call this a Crooked L-Wing. But I now get this. Thank you!
REPLY TO THIS POST

... by: Malikov

Tuesday 7-Jul-2009
Easy to understand concept.
REPLY TO THIS POST
Article created on 11-April-2008. Views: 750226
This page was last modified on 27-December-2014.
All text is copyright and for personal use only but may be reproduced with the permission of the author.
Copyright Andrew Stuart @ Syndicated Puzzles, Privacy, 2007-2024
Playwire