Sudoku Y Wing Technique with Examples

Coordinates are settled onto the grid,
now what, pray tell, are we to forbid?
'tis not easy quite for sure to say,
but with these wings we might flight them away.

Welcome! If this is your first visit to my blog, you may wish to read some of the other blog pages first. Links are to the right, along with publish date. The blog has been progressing through techniques relative to approximate difficulty.

Most places with tips, techniques, tricks about how to solve sudoku puzzles include not only what this blog has tackled up to this point, but also Y wings.

Nevertheless, in my opinion, most techniques are presented but narrowly. This page will not only introduce Y wings, also called xy wings, but also generalize the concept. Including Y wing style in your bag of solving tricks will help in tackling truly difficult puzzles. Furthermore, such inclusion will beg further generalization that will help to logically solve just about every sudoku puzzle.


Y wing as a triple


triple as ywing

Note the naked triple illustrated above forbids 1,2,3 from all the blue cells. This is not normally thought of as a Y wing, but rather as a triple.


Y wing example


First Ywing Example

In this example we have moved things around a bit. This is a standard Y wing configuration. Here, candidate 1 is forbidden from all the blue cells. Consider:

  • The vertex of the Y wing, cell h1, is limited to one of {2,3} Consider both of these possibilities:
    • h1=2 forbids e1=2, thus e1=1
    • h1=3 forbids i3=3, thus i3=1
  • Thus, at least one of the endpoints {e1,i3} of the Y wing must be 1
  • Conclude: Whether h1=2 or h1=3: d3,e3,f3,g1,i1 are not 1

In a proof, one might write this step as:

  • ywing at e1=12, h1=23, i3=13 forbids def3,gi1=1 OR
  • e1=1 == e1=2 -- h1=2 == h1=3 --i3=3 == i3=1 forbids def3,gi1=1
A previous blog page, Coloring, explains some of the forbidding chain lingo above.

The typical Ywing is formed by 3 cells limited to two values each. The endpoints of the Y determine what is excluded. The vertex of the Y must see the two endpoints. In every case, all the cells seen by these endpoints are the target for the exclusions.

Another Y wing example


Second Y wing example

The example above is precisely the same as the previous one, except but one cell is the target for potential eliminations. The cells seen by the Y wing endpoints,{e1,h4}, are only {e4,h1}. Since the vertex h1 of the Y wing is already empty of 1's, 1 can be excluded only from the cell e4.

Extensions of the Y wing idea


The following forbidding matrix exposes the logic of a typical Y wing:


cell x = r cell x = s  
  cell y = s cell y = t
cell z = r   cell z = t

To understand this forbidding matrix, consider:

  • The empty cells are FALSE
  • The entries in the filled cells are boolean variables - thus true or false
  • r,s,t are individual candidates - integers
  • Each row is a strong set. Meaning: There is at least one true item in each row
  • Each column, except the first column, is a weak set. Meaning: There is at most one true item in each of these last two columns
  • Therefor, the matrix contains at least three truths
  • Also, The last two columns contain no more than two truths
  • Finally, the first column must contain at least one truth
Clearly, all cells seen by both cell x and cell z cannot contain r.

A Y wing considers strength in cells to deduce strength in candidate location. This is a tad specific for my taste. Most techniques, tips, tricks about how to solve sudoku puzzles stop before they generalize ideas.

To extend the idea of a Y wing simply remove the restrictions. Instead, consider strength in any container - cell, box, column, row - to deduce strength in any container.

Y wing style is then any consideration of three strong sets that proves an elimination.

If you are paying attention, the restriction here of three is also artificial.

The following list examines all the previous techniques covered in this blog, relative to what they are looking at and what deductions they allow:

Unique Possibilities
Finds singular strengths in any container
Locked Candidates
Looks at strength in location of one type of candidate in one large container (row, column, box) to deduce strength of that candidate in location
Naked Pairs, Triples and Quads
Looks at strength of N candidates in N cells to deduce strength of those N candidates in N locations within a large container(s)
Hidden Pairs, Triples and Quads,...
Looks at strength of N candidates in N locations within a large container(s) to deduce strength of those N candidates in N cells
X Wing
Swordfish
Looks at strength of one type of candidate in N rows(location) to deduce strength of that candidate in N columns(location) OR vice versa
Unique Rectangles
Looks at potential symmetrical overlapping strength of candidates in location to deduce strength of any type
Coloring
Looks at strength of one type of candidate in location to deduce strength of that candidate in location
Y wings
Looks at strength of 3 cells containing exactly 2 candidates each. Considers 3 types of candidates. Deduces strength of one of those candidates in location
Y wing style
Looks at 3 native strengths of any type to deduce strength(s) of any type
Forbidding Chains
Looks at any number of strengths of any type to deduce strength(s) of any type

Stay tuned, as the next blog will examine the power of Y wing styles. The following tough puzzles can be solved using Y wings plus perhaps techniques covered in previous blog pages. If you get stuck, there should be cryptic proof(s) on the puzzle page.

Find information about me, Steve, at the first page of this blog and My Page at sudoku.com.au.

25 Comments
Indicate which comments you would like to be able to see

Steve  From Ohio    Supporting Member
Check out my page
May the year 2{James Bond} be filled with joy, prosperity, and love for each and every being!


to 2007!

Pam  From sw ontario
Haven't had time to sit and concentrate on this, as yet. Thanks, you have made it sound much easier than I anticipated.

Happy New Year
JoAnne  From TX
Okay, Steve, I've printed one of the tough puzzles you suggested; now I'll see if I can find the Y wing. Thanks for the blog! It's helpful.
Tricia  From Queensland    Supporting Member
Check out my page

Thanks for your solutions I am still a little further back with the swordfish etc but it is helpful
kateblu  From Madison WI    Supporting Member
Check out my page
Wow! Happy New Year.
pChu  From Hong Kong
Please confirm the last but one comment about the forbidding matrix:
'Also, The last two columns contain no more than two truths'
Steve  From Ohio    Supporting Member
Check out my page
Hi pChu!
I probably should have explained a bit better:

At any rate, when I wrote: in a typical Y wing, the vertex must 'see' the endpoints,
it means that cell y, the vertex here, shares a container with cellx and that it shares a container, perhaps a different one, with cell z.
Therefor, it is clear that each column can have no more than one truth, hopefully.

Thank-you for your question. I will eventually change the wording in the blog to make it more clear.
pChu  From Hong Kong
Dear Steve,
Thank you for your response. Yes, I can see that each of the last two columns can't have more than one truth. The 4th comment already clearly stated that. But that is why I asked, because it seems to say otherwise. Moreover, there are only 2 non-empty cells each in those columns!
Soozn  From NZ
Happy New Year all

Steve, is there a simple way to put it so that I can figure out the endpoints and the vertex of a Y wing/ Sometimes I see what looks like it in a puzzle but it takes me a while to figure out which numbers to exclude where. I usually do the 'working out' like in your example, but I am sure there is a shorthand way to see what to exclude.
Thanks
Steve  From Ohio    Supporting Member
Check out my page
Hi pChu!

I am sorry that I was not clear enough in my explanation.

The idea of the forbidding matrix is to expose the logic behind the technique.

All the entries, except the empty cells, in the matrix are boolean variables that are either true or false.

The blank cells are false.

We are counting only truths here - sort of like Gaussian elimination, in a way.

Since it is presumed that cell x and cell y share a large container, clearly there can only be one truth in second column.

Since it is presumed that cell y and cell z share a large container, clearly there can only be one truth in the third column.

Since there are at least 3 truths in the matrix, but no more than two in the rightmost two columns, there can only be one truth
in the first column. Thus, all cells seen by both cell x and cell z cannot contain r.
Steve  From Ohio    Supporting Member
Check out my page
Hi Soozn!
Not sure there is an easier way than:
The vertex must 'see' the endpoints. The containers it sees them through will generally be at least two of {box,column, row} (unless it really was a triple as in first example)

I found Y wings very hard at first. It takes practice. The concept - not hard. Putting the concept into use in a puzzle - not so easy.

The crux to logically solving sudoku puzzles, after getting through the techniques discussed first in this blog - is really finding the chains. Understanding them - not that hard. Finding them - that is vexing.

Using a program like Simple Sudoku that allows you to highlight cells can help.
Steve  From Ohio    Supporting Member
Check out my page
I have edited the blog page to reflect some of my discussion with pChu.
Please, if you find something I have written unclear, let me know.
I am quite happy to fix my errors, omissions.
Steve  From Ohio    Supporting Member
Check out my page
One futher note:
Suppose something were to happen on the puzzle grid so that one of the two rightmost columns had no truths in it. Then the other rightmost column would have one truth, and the first left column would have two truths. In this case, we would still forbid exactly the same things, as we need only at least one truth in the first column.
Steve  From Ohio    Supporting Member
Check out my page
hmmm talking about the forbidding matrix, still, with my last comment. Will try hit submit slower in the future.

pChu  From Hong Kong
Dear Steve,

A glitch in my mind forbade me in understanding the explanation. Sorry for making all the trouble. The explanation now comes out crystal clear. Thank you for your effort.

Happy new year.
kateblu  From Madison WI    Supporting Member
Check out my page
Happy New Year Steve, I'm working on the tough puzzle for 11/3 and eliminating numbers like a madwoman and although I don't usually see why it works, I can check and see that it does work. However I get to this point in the bottom three/left six rows:

3147 4714
2219 19
13549352927 479
abcde f

I used the b1,2/d3 y-wing to eliminate 4s at b3 and d1. Why doesn't the b1/d2/d3 y-wing eliminate the 9 at d1?

If the formatting doesn't make it through the email, my question will seem like gibberish and I apologize.
kateblu  From Madison WI    Supporting Member
Check out my page
I see that the formatting didn't get through. The general question is that the y-wing doesn't seem work all the time. It seems that the vertex should be both of the two cells that complete a rectangle with the end-points. If one of the endpoints is in that cell, it can be eliminated. By that thinking there are potentially six vertices for each y-wing. Of course, they may already be allocated or not have the endpoint number in them.
Steve  From Ohio    Supporting Member
Check out my page
Hi Kate!
Not sure that I really understand your question:
But....
There can never by a Y wing formed by the cells b1,d2,d3 - since b1 does not 'see' d2 nor d3 meaning b1 does not share a container with d2 or d3.

Done properly, a Y wing always 'works'. It cannot fail:

Given three cells, the vertex must see the endpoints.
Contents of cells:
Let rs be in endpoint x
Let st be in vertex y.
Let tr be in endpoint z.

Only the r, common to both endpoints, can be eliminated from cells 'seen' by both cells x,z.
kateblu  From Madison WI    Supporting Member
Check out my page
Thanks, Steve. I understand that the cells that can be eliminated have to be in the same row, column or block as the two endpoints. My error was not realizing that the vertex also has to share a row, column or block with each of the endpoints.
andrei  From US
Hi Steve! I find your '5-bullet' analysis of the Y-wing example a little too heavy. The following argument seems to be a little more transparent.

The cell h1 (the VERTEX of the Y-wing) has two candidates 2 and 3; setting h1=2 forces e1=1, while setting h1=3 forces i3=1. In either case, one of the ENDPOINTS e1 and i3 is filled with 1, forbidding 1 in all cells (blue cells in your example) linked to (i.e., sharing a row, column or block with) each of them.
Steve  From Ohio    Supporting Member
Check out my page
Excellent point andrei!

Thank-you for your suggestion.

I do tend to 'push' my explanations in one direction, when often a better approach is to use a center point of strength.

I may edit the presentation to reflect your idea.

chris  From north carolina
thanks steve! i just learned y wing from your example. very simple to understand from your illustration. thanks again
jessie  From perth
hi im jessie and i am only thirteen and i have only just discovered how to actually play sudoku and if i could i would do it every second for the rest of my life.It is hard sometimes but it really gets your brain working!!!! luv ya all jess
JIZM  From CUBA
QUESTO SI PALLIACI !
armando  From portugal
If you want to try out something new in sudoku, try shendoku, using the sudoku rules but playing two people, one against the other, like battleshipps. They have a free version to download at http://www.shendoku.com/sample.pdf . Anything else they are bringing out or they are working on you can find at www.shendoku.com or at they´r blog www.shendoku.blogspot.com . Have fun, I am. I specially like one slogan I heard about Shendoku: SUDOKU is like masturbation (on your own)…. SHENDOKU is like sex (it takes two).
24/Sep/07 7:53 AM
Please Log in to post a comment.

Not a member? Joining is quick and free. As a member you get heaps of benefits.

Join Now Login