Sudoku Programmers Forum Index

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in          Games  Calendar

Log in to check your private messagesLog in to check your private messages   

Understanding Swordfish
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Solving sudoku
View previous topic :: View next topic  
Author Message
AndyT

Joined: 27 Jan 2006
Posts: 15
:
Location: Hong Kong

Items
PostPosted: Fri Jan 27, 2006 4:20 am    Post subject: Understanding Swordfish Reply with quote

Guys, I'd appreciate some help understanding the Swordfish technique. I've seen it discussed in a number of places, not least in Angus' excellent program. In fact, that's a great place to start because I don't even follow his explanation in the help file. The demo puzzle looks like this:

However, the explanation:
Quote:
Three columns (two, five & eight) have candidate 5 in no more than three cells (two cells each in this case), and these cells all share the same three rows (one, four & nine). A "Swordfish" pattern is established. Other cells with candidate 5 within this grid (highlighted yellow) can be excluded safely.
baffles me. He excludes a 5 at R1C4 but not at R3C4. Why? Also why was column 4 not consider at the start? I just can't visualise the swordish or the starting parameters.

Which brings me onto a separate puzzle that looks like this:

Angus' program suggests a Swordfish exclusion of 4s but again I can't see how the grid works or why some 4s stay while others go.

I accept I'm probably being dumb but I guess the most obvious things are confusing until somebody turns the light on!

Thanks in advance.
Back to top
View user's profile Send private message
md68

Joined: 25 Jan 2006
Posts: 3
:

Items
PostPosted: Fri Jan 27, 2006 4:34 am    Post subject: Reply with quote

I have problems too to understand it but maybe this explanation helps you out:

http://www.sudokuoftheday.com/pages/techniques-9.php

If you have figured it out then let me know Smile
Back to top
View user's profile Send private message
angusj
Site Admin
Joined: 18 Jun 2005
Posts: 406
:

Items
PostPosted: Fri Jan 27, 2006 7:04 am    Post subject: Re: Understanding Swordfish Reply with quote

AndyT wrote:
Guys, I'd appreciate some help understanding the Swordfish technique.

Yes, it's tricky to understand and trickier to explain Wink.

I'll try again here, but here's the Swordfish explanation on my website which I've updated and is hopefully now a little clearer. (Understanding Swordfish is a bit like bicycle riding - a bit tricky until you know how.)

Firstly, remember that each column and row (and box) must contain one and only one of each digit otherwise it's not a valid Sudoku.

Taking the first example above and filtering on candidate 5s ...
Columns 2, 5 & 8 each have three or less candidate 5s that between them occupy exactly three rows.

Therefore, whichever way you place the '5' digit within these columns (ie promote the the '5' candidate to the digit), each of the three rows will also have exactly one 5 digit assigned from within these columns. No row can escape from having a 5 digit assigned from one of these columns otherwise another row would have more that one 5 digit which isn't allowed.

Since these three rows (1, 4 & 9) must have a 5 digit assigned from within the three columns (2, 5 & 8) then any other candidate 5s in these rows but not in these columns can be excluded.

Note- this logic also holds true when swapping rows and columns in the explanation above (as is demonstrated by the second puzzle).

In the second puzzle, filter on candidate 4s.
Rows 1,6 & 7 have no more than three of candidate 4 in each of these rows, and these three rows have this candidate occupying the same three columns (1,2 & 7).

Therefore, whichever way you place the '4' digit within these rows, each of the three columns will also have exactly one '4' digit assigned from within these rows. No column can escape from having a digit assigned from one of these rows otherwise another column would have more that one '4' digit which isn't allowed.

Since these three columns (1,2 & 7) must have a digit assigned from within the three rows (1, 6 & 7) then any other candidate 4s in these columns but not in these rows can be excluded.

Exercise: In the second puzzle and using the blue cells only, try and place one digit '4' in each of row 1,6 & 7 such that none of the columns (1,2 & 7) has more than one digit '4' and one of the columns has no digit '4'. (Hint: it's not possible.)

Tip: Draw imaginary lines horizontally and vertically through the blue colored cells. Any cells crossed by these lines that aren't blue can safely have the specific candidate excluded.


Last edited by angusj on Mon Jan 30, 2006 9:33 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
AndyT

Joined: 27 Jan 2006
Posts: 15
:
Location: Hong Kong

Items
PostPosted: Mon Jan 30, 2006 9:08 am    Post subject: Reply with quote

Thanks for taking the time, Angus but, even having read the verbose version, I'm baffled. Worse I'm not doing too much better with Colours. This came up as a hint:



Now I have no idea where the colour mapping started but if you end up in the bottom left box, what's the problem? R5C2 and R9C2 and R8C5 are blue so force R8C2 to be green. So that makes R8C1 blue and R7C1 green. So 2 greens in column 1. How does this display lead to the conclusion that blue is wrong for 5s? It also appears sensitive to the starting cell.
Back to top
View user's profile Send private message
angusj
Site Admin
Joined: 18 Jun 2005
Posts: 406
:

Items
PostPosted: Mon Jan 30, 2006 10:26 am    Post subject: Reply with quote

AndyT wrote:
Thanks for taking the time, Angus but, even having read the verbose version, I'm baffled.

Yes, it's tricky, and I'm sure my explanations can be improved. I'll have another go at it at some stage.

AndyT wrote:
Now I have no idea where the colour mapping started ... It also appears sensitive to the starting cell.

No, it's definitely not dependant on where you start coloring. However, what is crucial is that, whereever you start, you only color conjugate cells. If you reach a point where a group has two or more cells of one color (eg column 2 in the example you've posted) then that must be the 'false' color.
Back to top
View user's profile Send private message Visit poster's website
AndyT

Joined: 27 Jan 2006
Posts: 15
:
Location: Hong Kong

Items
PostPosted: Mon Jan 30, 2006 10:42 am    Post subject: Reply with quote

But if I go from R7C5 left to R7C2, that cell gets coloured green.

If I go down from R4C1 green, that makes R7C1 blue and the cell beneath it green thus column 1 has 2 green cells and green is false.

I appear to be able to make either colour false.
Back to top
View user's profile Send private message
angusj
Site Admin
Joined: 18 Jun 2005
Posts: 406
:

Items
PostPosted: Mon Jan 30, 2006 10:55 am    Post subject: Reply with quote

AndyT wrote:
But if I go from R7C5 left to R7C2 ...

Are you asking about the 'colors' problem you posted above???
If so then asking about these particular cells just doesn't make sense to me since none of them have candidate 5s.
Back to top
View user's profile Send private message Visit poster's website
AndyT

Joined: 27 Jan 2006
Posts: 15
:
Location: Hong Kong

Items
PostPosted: Mon Jan 30, 2006 11:09 am    Post subject: Reply with quote

Yes. Why are all four 5s in the bottom left box not candidates?
Back to top
View user's profile Send private message
angusj
Site Admin
Joined: 18 Jun 2005
Posts: 406
:

Items
PostPosted: Mon Jan 30, 2006 11:55 am    Post subject: Reply with quote

AndyT wrote:
Yes. Why are all four 5s in the bottom left box not candidates?

One of them is - r9c2 (colored blue) as it's a conjugate with r9c6 (colored green).

Perhaps you're confused by the darker green cells which just highlight the cells containing the '5' candidates as opposed to the blue and bright green cells which are the conjugate cells? I don't think I can help you much more. I suggest you have another look at colors here - http://angusj.com/sudoku/hints.php#colors
Back to top
View user's profile Send private message Visit poster's website
AndyT

Joined: 27 Jan 2006
Posts: 15
:
Location: Hong Kong

Items
PostPosted: Mon Jan 30, 2006 2:06 pm    Post subject: Reply with quote

Angus, I appreciate both your time and your frustration but I've done enough teaching (in the air) in my life to know that things can be really obscure until just the right explanation hits you.

I may be getting there - standby!
Back to top
View user's profile Send private message
Henk

Joined: 13 Nov 2005
Posts: 105
:

Items
PostPosted: Mon Jan 30, 2006 4:08 pm    Post subject: Reply with quote

I have also written an explanation of Colors and Swordfish. The images maybe help you understand it. It is not very well written, but it might help you in combination with the writing of angusj.

http://www.intosudoku.com/Doc/Colors.html
http://www.intosudoku.com/Doc/MultiColors.html
http://www.intosudoku.com/Doc/SwordFish.html
http://www.intosudoku.com/Doc/ForcingChain.html
_________________
Generate and solve Sudoku puzzles with Into Sudoku!


Last edited by Henk on Tue Jan 31, 2006 9:53 am; edited 1 time in total
Back to top
View user's profile Send private message
AndyT

Joined: 27 Jan 2006
Posts: 15
:
Location: Hong Kong

Items
PostPosted: Tue Jan 31, 2006 6:41 am    Post subject: Reply with quote

OK, guys, for the last time then I can go and quietly shoot myself! Here's a final example from one of Angus' puzzles that lends itself nicely to colours but - to me - is critical of order:



The plan is to identify spurious 9s. So I started at R6C1 and made that blue. Thus
R4C3 green
R3C3 blue
R2C1 green
R3C4 green
R3C5 blue (!)
R2C9 blue
R1C7 green
R1C5 blue
hence R3C5 green ... but it's already blue!

This suggests to me that this "build" placed 2 blue cells in row 3 - thus blue is not 9, hence R3C4 green is 9. Wrong.

Clearly you have a neat algorithm in your code that deduces the outcome. However, there still seems to be a line missing from the verbal Rules of Colours that I can't see.

Where is this logic flawed?

Thanks, guys!
Back to top
View user's profile Send private message
Ruud
Site Admin
Joined: 17 Sep 2005
Posts: 708
:
Location: Netherlands

Items
PostPosted: Tue Jan 31, 2006 7:51 am    Post subject: Reply with quote

Hi Andy,

unfortunately, you cannot assign a color to R3C5, because it is not a conjugate of any of the other colors you identified.

In this situation, you cannot proceed with coloring.

However, you can spot an XY-Wing in the following cells:
R4C7 {5,9}
R4C6 {5,3} = 3 when R4C7 = 5
R6C8 {9,3} = 3 when R4C7 = 9
R4C8 {-3} (eliminated)

I shall not even attempt to explain this technique... Wink
But it does break the puzzle.

Ruud.
_________________
Meet me at sudocue.net
Back to top
View user's profile Send private message Visit poster's website
AndyT

Joined: 27 Jan 2006
Posts: 15
:
Location: Hong Kong

Items
PostPosted: Tue Jan 31, 2006 8:32 am    Post subject: Reply with quote

But Angus' program offers Colors as a hint here and proceeds to remove the 9 from R3C4.

Thank you for not explaining XY!! You may have saved my sanity.
Back to top
View user's profile Send private message
angusj
Site Admin
Joined: 18 Jun 2005
Posts: 406
:

Items
PostPosted: Tue Jan 31, 2006 9:01 am    Post subject: Reply with quote

AndyT wrote:
But Angus' program offers Colors as a hint here and proceeds to remove the 9 from R3C4.

I'm sure Simple Sudoku's hint feature wouldn't color the cells in the way you've illustrated.

AndyT wrote:
R3C4 green

NOOOoooo.

Smile
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Solving sudoku All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Sudoku Programmers topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group

Igloo Theme Version 1.0 :: Created By: Andrew Charron