Finally the time has come to explain the Sudoku Swordfish rule! I've noticed this is one of the most popular search terms leading to this blog, so I'm happy to be able to help out.
Consider this board:
Following elimination, we reach the position below. I've highlighted some areas in red. In row 5, there are two places where we can place a 9, in columns 4 and 6. In row 7, 9 can appear in columns 4 and 9 only, and in row 9 it can appear in columns 6 and 9 only.
The curved red lines show how the cells involved in the swordfish form a kind of loop. Placing a value in one of the cells implies its positions in the rest of the loop. Suppose the 9 in row 5 appears in column 4, that is, in cell (4, 5). Then cell (6, 5) can't contain a 9, so cell (6, 9) must (because it's the only other place in column 6 than can). That implies that (9, 9) can't contain a 9, so (9, 7) must. Alternatively, if the 9 in row 5 appears in cell (6, 5), following things around the loop we see that 9's must also appear in cells (9, 9) and (4, 7). Either way, we've placed a 9 in each of the three columns 4, 6, and 9. We can eliminate any other possible 9's in those columns, namely the ones highlighted in blue.
Another way to see things is to notice is that there are three 9's to be placed in three rows (5, 7, and 9), and exactly three columns (4, 6, and 9) intersecting those rows where they can be placed. Each column must receive a 9 in one of the three rows.
The swordfish can also appear in a vertical orientation. In this case, we notice three columns that each can take a given number only in two places. Between the three columns, the places that can hold that number fall into exactly three rows. The board below provides an example:
I've highlighted the vertical swordfish (on the number 3) in the grid following eliminations:
The 3's can be removed from rows 4, 6, and 7 (outside of columns 1, 4, and 9 that make up the swordfish).
A swordfish could also involve three rows (or columns) that each have the same three possible places for a number. Say the value is placed in the upper-leftmost cell of the pattern; then the lower-left cell (which lies in the same column) can no longer hold the value. The remaining cells form an X-Wing pattern. The same X-Wing appears if the value belongs in the lower-leftmost cell. I'll try to come up with an example of this type of swordfish in the near future.
So, to summarize, the pattern consists of three rows, and a total of three columns within those rows where a given value can be placed. The value can be removed from the remainder of those columns. The same rule applies if the words "row" and "column" are switched.
I hope this helps to clarify the Swordfish rule!
Technorati Tags:Su Doku Sudoku
The coordinates you use in the example of the swordfish do not seem to make sense. I'm trying to learn how to apply the swordfish technique to a su doku puzzle. You say that column 4 row 5 is (4,5) and if that cell contains a nine then (4,6) can't contain a 9 and cell (4,9) must. However, cell(4,6) and (4,9) both cannot contain 9's not just because there is a 3 located in (4,6) based on your coordinates and a 1 in (4,9) but also because you can't have two 9's in column 4. I'm fairly sure its just a labeling/typing error you made unless there's something i'm overlooking. Anyway, thanks for the help on the x-wings and the grids. Hopefully you can fix this soon to make it easier to understand.
Matt
Posted by: Matt | August 24, 2005 at 06:02 PM
Thanks, Matt, I have made some changes and hopefully things should be fixed now. -Dan
Posted by: Dan Rice | August 24, 2005 at 07:32 PM
The first swordfish starts off after elimination. But it seems to me that the elimination missed that box 7 (lower left) can only hold a 9 in (2,8) and therefor we can elmininate the blue 9's in (4,8) and (9,8) and thus making the whole swordfish moot.
/Patrick
Posted by: Patrick Forsberg | September 23, 2005 at 08:04 AM
Hi Patrick -
You are quite right -- the 9 can be placed in box 7 using the "eyeball" rule, so the first Swordfish is not necessary. The rules that are used in a given puzzle will always depend on the order in which they are applied. Arguably, a complex rule like Swordfish should be saved until all other options have been exhausted, since it can take a lot of work to find one.
My program missed this because it applied only the rule of elimination to cross out numbers. Strictly speaking, it is the rule of uniqueness that would allow the 9 to be placed, by observing that there is no other place for it in box 7.
Thanks for your comment!
Posted by: sudokublog | September 24, 2005 at 04:22 PM
I don't understand in your second example (with the swordfish in columns 1, 4, 9) why column 7 can't be part of the swordfish since it has 3's in the same 3 rows?
Thanks
Posted by: Larry | September 28, 2005 at 02:22 PM
I didnt understand your explanation of the vertical and horizontal swordfishes or why they worked. Could you describe them in detail?
Posted by: tom | January 16, 2006 at 10:38 AM
To Larry from 9/28/05: If I understand correctly, I believe you have to start with columns that have only (exactly) 2 occurrences of the number.
Posted by: chris | January 27, 2006 at 11:56 AM
maybe a good example for the last point
3-1 958 -6-
*-8 *-4 5*1
*-4 2-- 3*8
*4- *-9 8*6
61- 8-5 -39
8-9 6-- -1-
--- --6 9--
296 4-- 1--
-8- -9- 6-7 * = swordfish(7)
Posted by: Ernesto | March 04, 2006 at 04:31 PM
Dear Dan, Just out of curiosity, how long did u take to solve the above Sudoku ? Monica
Posted by: Monica | March 07, 2006 at 05:12 AM
"Alternatively, if the 9 in row 5 appears in cell (6, 5), following things around the loop we see that 9's must also appear in cells (9, 9) and (4, 7). "
Why? (6,5) -> (9,9) But (4,7) and (4,8) are both valid, looking only at the 9s.
Posted by: Gunter | August 17, 2006 at 02:40 AM
Your X Wing and the Swordfish example
both contain candidates that appear more than twice , making these candidates invalid and removable !
Your explanation of X-Wing, SwordFish is very clear, and your examples that include invalid candidates are the best I have seen so far.
++++++++++++++++++++++++
On another subject: Now that I can understand sudoko...I am curious:
1. Is the level of diffculty programmed into a puzzle
OR
must huge nymbers of computer programmed puzzles be solved in order to locate
the most difficult puzzles
that require X Wing and Swordish ?
2. Are there computer programs that can solve
sudoko without human intervention ?
martine
Posted by: martine | March 19, 2008 at 02:33 PM
Martine, I can answer your second question. There is a very simple computer algorithm that can solve any sudoku. It relies on a technique called "Depth First Search". A implementation of this would print on a single page of paper.
But for humans it is a terrible algorithm to simulate. It's the same thing you do when you're stuck and you make a guess. Then you work the puzzle until it is either solved or a contradiction occurs. When a contradiction occurs you must backup and rechoose your most recent decision.
Even for the hardest puzzles it will solve it in a fraction of a second.
Posted by: Jeff | December 15, 2008 at 10:17 AM
what about this one
4 4 4
4 4
4 4
and this
4 4
4 4 4
4 4
HELP
joseph
Posted by: joseph | June 08, 2009 at 09:45 AM
In the first puzzle there is another Swordfish (more difficult to see) so as well as nines there is for one for ones. It took me more than ten minutes to see it. I have a software program than told me there was a Swordfish in ones but I did not use the software to show me the Swordfish as I like to see if I understand how to look for a Swordfish. I'm glad to say that I solved it. The Sword fish is a 2-2-2 Swordfish and the elignment (ones that are eliminated) is horizontal. Now what might confuse people is when they look at the answer you might think the enlignment is virtical.
I've just made a descovery which is suprising and that is there are two swordfish solutions for the ones. The solution I found is correct as the exact same candidtates were eliminated in the other solution. The second solution was the solution showed by my software and the Swordfish config is a 3-2-2 and the elignment for the eliminated candidates is virtical so meaning that they are eliminated virticaly and in the 2-2-2 solution the eliminated candidates are eliminated horizontaly. Once you see the solution for both, any one reading this will then or should understand what was mentioned by enlignment horizontal and vertical, so have a go and see if you can solved both Swordfish solutions for the candidate no one.
Posted by: DolphinT7 | January 17, 2010 at 01:16 AM
hi, i tried to subscribe. it kept coming up bookmark instead of subscribe. i want to start coming here.
diana
Posted by: diana carr | January 19, 2010 at 01:04 PM
i am a newbie, in love with sudoku. what do players use to write on their sudoku. i have an erasable soduko board, what else could be used over and over again.
diana89128@cox.net
Posted by: diana carr | January 27, 2010 at 02:17 PM
Well explained . Thanks. I was searching for sudoku swordfish explanation.
Posted by: Proactol Scam | June 09, 2010 at 02:47 AM
I adore sudoku . I'm not best player though :)
Posted by: Fibretrim Review | July 13, 2010 at 02:46 PM
You're a braver woman than I it was weeks before I could even begin to think about looking at the incisions from my lap. Even now I don't like to touch them.
They're...squishy.
Posted by: christian louboutin | October 29, 2010 at 07:32 PM
[Quote]
Alternatively, if the 9 in row 5 appears in cell (6, 5), following things around the loop we see that 9's must also appear in cells (9, 9) and (4, 7).
[/Unquote]
Did you mean (7, 4), instead of (4, 7)?
Posted by: Dave | December 11, 2010 at 10:02 PM
Sounds like some smart technology company should hire the Hammer.
Posted by: authentic air jordan shoes | June 13, 2011 at 06:07 PM
nice chris.....cant wait to see you in cali.......o yea i almost forgot........i got 2 of there email
Posted by: ergo baby carrier sale | September 15, 2011 at 02:10 AM
thanks for the help on the x-wings and the grids. Hopefully you can fix this soon to make it easier to understand.
Posted by: ergo baby carrier | October 12, 2011 at 01:36 AM
I have a question, suppose there is a 9 in row 5 column 4, which will force 9 not to be there in row 5 column 6. Because column 6 in this case contains no other cell (apart from in row 9) where 9 is a candidate, this will force a 9 into row 9 column 6, right? But if there were another cell in column 6 with a 9 candidate, how could we proceed? In fact there is a similar situation here in the last column. Assuming a 6 in row 5 column 4, there can't be a 9 in row 9 column 9. From there you are telling that there has to be a 9 at row 7 column 9. But why, that 9 can be there in row 8 column 9 too, isn't it?
Posted by: Kaustav Mukherjee | December 11, 2011 at 12:44 AM