|
View previous topic :: View next topic |
Author |
Message |
| Puzzler
| Joined: 04 May 2009 | Posts: 36 | : | | Items |
|
Posted: Sat May 09, 2009 11:45 pm Post subject: Trying to understand color collisions |
|
|
In Angus' example of a puzzle containing colliding colors, he shows he following:
2. Cells with the same conjugate color sharing a group
Please could someone explain why {R5,C8} is blue and not green? If I follow the chain of colors, it would seem to me that this cell is a conjugate of {R9,C8}.
This makes a big difference because if it's green, the colliding chain is different. I think this is why my collision code isn't working - I'm coloring in the wrong order, perhaps because I'm choosing a different start cell.
Is there a rule I can apply to selecting which cells to color, in what order?
Thanks |
|
Back to top |
|
|
| daj95376
| Joined: 05 Feb 2006 | Posts: 349 | : | | Items |
|
Posted: Sun May 10, 2009 5:29 am Post subject: |
|
|
Cell [r5c8] is blue because it is a conjugate of cell [r5c1], which is green.
The rules for coloring aren't affected by where you start. However, the order in which you color the cells can sometimes affect where you detect a contradiction, but not which color has the contradiction.
In the example you selected, the contradiction will always appear between cells [r5c8] and [r6c9] in box 6. |
|
Back to top |
|
|
| JasonLion
| Joined: 16 Nov 2008 | Posts: 62 | : | Location: Silver Spring, MD | Items |
|
Posted: Sun May 10, 2009 12:58 pm Post subject: |
|
|
If R5C8 was the other color, R6C9 would also end up being the other color.
In this case there is a five cell chain that can never be colored without a contradiction:
R5C8, R5C1, R8C1, R8C9, R6C9
Because R5C8 and R6C9 are not a conjugate pair, and because of the chain, no coloring will ever end up with them being different colors
Different orders of coloring can change the color that is contradicted, but not the cells in which the contradicted color occurs.
Last edited by JasonLion on Mon May 11, 2009 1:12 am; edited 1 time in total |
|
Back to top |
|
|
| Puzzler
| Joined: 04 May 2009 | Posts: 36 | : | | Items |
|
Posted: Sun May 10, 2009 6:17 pm Post subject: How reliable is this method? |
|
|
I'm really missing a simple concept here.
There are so many ways to create chains that collide, depending on the exact sequence that you color the chains. Each collision appears "equally invalid", yet only one of the many 'invalids" is the right "invalid"
It just doesn't seem like a very reliable method. |
|
Back to top |
|
|
| PIsaacson
| Joined: 17 Jan 2006 | Posts: 47 | : | Location: Campbell, CA | Items |
|
Posted: Sun May 10, 2009 11:14 pm Post subject: |
|
|
Puzzler,
There are 11 possible conjugate pair starting positions for coloring this example:
Boxes - b1 r2c2-r2c3, b4 r5c1-r6c2, b7 r8c1-r9c3, b9 r8c9-r9c8
Rows - r1 r2c2-r2c3 (dup), r5 r5c1-r5c8, r8 r8c1-r8c9, r9 r9c3-r9c8
Cols - c1 r5c1-r8c1, c2 r2c2-r6c2, c3 r2c3-r9c3, c9 r6c9-r8c9
Regardless of where you start and which color you start with, simple conjugate coloring will always arrive at the "collision" in box 6 for r5c8 and r6c9. The great thing is that because you've used simple conjugate coloring, in this case all cells colored the same as the collision color can be eliminated:
r2c3<>9, r5c8<>9, r6c2<>9, r6c9<>9, r8c1<>9 and r9c8<>9 all at once.
They're conjugates and you've proven that one color is "false", so it should make sense as to why all the eliminations are legal. Try coloring all 11 possible start positions and remember to only color conjugates and this should start to make sense. Coloring is a handy tool to have at your disposal since it's kind of a mechanical process and doesn't require memorizing all the various fishing rules or spotting a pattern other than a conjugate pair to kick off the coloring algorithm. Personally, I like X-coloring for single digit analysis, but coloring in general is a very reliable and powerful technique, especially advanced multi-coloring such as 3d-medusa or GEM etal.
In answer to your original question, r5c8 is not a conjugate pair with r9c8 because of r6c8.
Cheers,
Paul |
|
Back to top |
|
|
| Puzzler
| Joined: 04 May 2009 | Posts: 36 | : | | Items |
|
Posted: Mon May 11, 2009 2:25 pm Post subject: Almost had it |
|
|
Hi Phil
Thanks for your help. It's much appreciated.
I've re-written my code and finally have it coloring correctly to solve the puzzled above.
My code checks for traps and collisions and works many of the test cases I have, but then comes unstuck on this one:
807090602952860040306020598781934256264000009539602004600000421120046980408210065
The code immediately finds a trap for 1 in {R1,C8}
Blue chain: {r1,c2},{r2,c6},{r9,c7}
Green Chain: {R2,C7},{r3,c2},r6,c8}
Conjugating pairs:
{R1,c2}->{R3,C1}
{r2,c6}->{r2,c7}
{r6,c7}->{r6,c8}
All of the conjugates are correct, and there is quite clearly an intersection between green and blue chains so I'm puzzled why this trap is wrong. There must be an additional rule I'm not aware of.
Could you shed some light for me?
Thanks |
|
Back to top |
|
|
| Puzzler
| Joined: 04 May 2009 | Posts: 36 | : | | Items |
|
Posted: Mon May 11, 2009 4:56 pm Post subject: Programatic selection of colors |
|
|
In the following puzzle there is a collision for 1's in R1,C4 and r2,C5
I've tried selecting cells based on following the conjugate chain and by selecting cells in row/column order but in both cases end up coloring R1,c9 green, not blue.
I don't understand how to programmatically select colors in this puzzle
How does the program know which cells to color what color? It's obviously not random, but I'm damned if I can see how its doing it.
There HAS to be a consistent, repeatable method for cell selection, can anyone tell me what it is?
Thanks
Code: |
*-----------*
|548|..3|...|
|.67|4.9|835|
|9..|857|6..|
|---+---+---|
|.9.|.38|257|
|3..|57.|4..|
|875|294|163|
|---+---+---|
|689|745|312|
|...|9..|5..|
|.51|3.2|...|
*-----------*
*-----------------------------------------------------------*
| 5 4 8 | 16 126 3 | 79 279 19 |
| 12 6 7 | 4 12 9 | 8 3 5 |
| 9 123 23 | 8 5 7 | 6 24 14 |
|-------------------+-------------------+-------------------|
| 14 9 46 | 16 3 8 | 2 5 7 |
| 3 12 26 | 5 7 16 | 4 89 89 |
| 8 7 5 | 2 9 4 | 1 6 3 |
|-------------------+-------------------+-------------------|
| 6 8 9 | 7 4 5 | 3 1 2 |
| 247 23 234 | 9 168 16 | 5 478 468 |
| 47 5 1 | 3 68 2 | 79 4789 4689 |
*-----------------------------------------------------------*
|
|
|
Back to top |
|
|
| Lunatic
| Joined: 11 Mar 2007 | Posts: 166 | : | Location: Ghent - Belgium | Items |
|
Posted: Mon May 11, 2009 5:14 pm Post subject: |
|
|
Hi Puzzler,
In simple coloring, you can only consider single chains. Your example has more than one chain, and you cannot implement Simple Coloring logic on more then one of these chains at the same time. You must apply Multiple Coloring for working with two (multiple) chains.
In your example,
807090602952860040306020598781934256264000009539602004600000421120046980408210065
I can see 5 strong links (conjugating pairs) on candidate 1:
1) {r1,c2}->{r3,c2}
2) {r1,c8}->{r2,c7}
3) {r2,c6}->{r2,c7}
4) {r5,c4}->{r5,c6} (in the centre box)
5) {r6,c7}->{r6,c8}
Only conjugate pairs n° 2 and n° 3 will link up to form a (short) chain, but Simple Coloring will not deliver any eliminations.
Candidate 1, by the way, is locked in the centre box at row 5, eliminating 1 from both cells {r5,c7} and {r5,c8} _________________ Marc
~~~<><~~~<><~~~<><~~~<><~~~ |
|
Back to top |
|
|
| PIsaacson
| Joined: 17 Jan 2006 | Posts: 47 | : | Location: Campbell, CA | Items |
|
Posted: Mon May 11, 2009 5:19 pm Post subject: |
|
|
Puzzler,
The conjugate pair r1c2-r3c2 stands alone. There are no conjugate links to the other colored pairs, so its coloring cannot participate in any deductions.
7 conjugate pairs: b1 r1c2-r3c2, b3 r1c8-r2c7, b5 r5c4-r5c6, r2 r2c6-r2c7, c7 r2c7-r6c7, c8 r1c8-r6c8.
b1 r1c2-r3c2 stands alone - cannot participate in other colorings
b5 r5c4-r5c6 stands alone - cannot participate in other colorings
According to templates, there are no single digit eliminations possible for the 1s after the initial r5c78<>1 from a box/line pointing pair. However, the 3s and the 7s are vulnerable, at least to X-coloring. Loading the grid into SS and using X-coloring starting from the conjugate pair r1c8-r5c8 quickly leads to r1c8<>3. Try simple coloring starting with 3r1c8 blue (true) and then extend the green false lines. B2 becomes totally green from r1c8 and r9c6 blue, so the initial premise (r1c8 true) is false and it can be eliminated.
Step by step - filter on three:
1) r1c8 = blue => r1c46, r2c79, r5c8 = green (all the peers colored false)
2) r5c8 = green => r5c7 = blue (conjugate pair)
3) r5c7 = blue => r9c7 = green (peers colored false)
4) r9c7 = green => r9c6, r8c9 = blue (conjugate pair + from r2c9 = green for r8c9 conjugate pair)
5) r9c6 = blue => r27c6 = green (all peers colored false)
At this stage box 2 is colored all green, so the original premise is false and r1c8<>3.
Hope this helps,
Paul
Last edited by PIsaacson on Mon May 11, 2009 6:45 pm; edited 1 time in total |
|
Back to top |
|
|
| Lunatic
| Joined: 11 Mar 2007 | Posts: 166 | : | Location: Ghent - Belgium | Items |
|
Posted: Mon May 11, 2009 6:10 pm Post subject: |
|
|
Puzzler wrote: | I've tried selecting cells based on following the conjugate chain and by selecting cells in row/column order but in both cases end up coloring R1,c9 green, not blue. |
If i follow the strong links in row/column order, starting with cell {r1,c4} then the chain is formed as follow:
{r1,c4} green
column
{r4,c4} blue
row
{r4,c1} green
column
{r2,c1} blue
row
{r2,c5} green => collides with {r1,c4} so green is wrong color
No more nodes can be linked to that chain if you don't link over boxes as well: {r4,c4} conjugates with {r5,c6} in the centre box:
{r4,c4} allready blue
box
{r5,c6} green
row
{r5,c2} blue
column
{r3,c2} green
row
{r3,c9} blue
column
{r1,c9} green => collides with {r1,c4} too
....and {r5,c6} conjugates with {r8,c6} in column 6:
{r5,c6} allready green
column
{r8,c6} blue
row
{r8,c5} green => collides with {r2,c5} (of course green, as it allready turned out to be the wrong color) _________________ Marc
~~~<><~~~<><~~~<><~~~<><~~~ |
|
Back to top |
|
|
| Puzzler
| Joined: 04 May 2009 | Posts: 36 | : | | Items |
|
Posted: Mon May 11, 2009 8:26 pm Post subject: Thanks! |
|
|
Phil and Marc,
Thanks for your help. I believe I have nailed the code now. At least, it works for the test cases I have.
My breakthrough was the realization that I was colliding and trapping against cells in different chains. I was confusing one chain with two colors and two chains of the same color. Thanks guys for pointing that out to me.
Marc, you mentioned that this technique only works if you have a single chain. I'm finding with the test cases I have that it doesn't matter if I have more than one chain, as long as I only test one chain at a time. Is this correct, or have I just been lucky in my test cases?
I'm intrigued by the x-colors technique and may try to implement this too, but for now, I'm exhausted and I think I'll rest my brain for a day or two!
Regards
Kevin |
|
Back to top |
|
|
| PIsaacson
| Joined: 17 Jan 2006 | Posts: 47 | : | Location: Campbell, CA | Items |
|
Posted: Mon May 11, 2009 11:25 pm Post subject: |
|
|
Pseudo code for X-coloring (plus) algorithm Code: |
for each digit in 1..9
find all conjugate pairs for digit in grid -> build conj_pair table
for each entry in conj_pair table
initialize coloring grid // mini grid but still needs all 4 rc/rn/cn/bn domains
mark 1st cell in entry with '+' parity (true) // begin first of two passes
do
assign '+' parity on coloring grid using naked/hidden singles logic
assign '-' parity on coloring grid using row/col/box interactions
until done
for each sector in 1..27
count total set '+' parity and '-' parity this pass
if count '+' parity > 1 or // multiple true
count '-' parity == total number possible candidates // all false
first premise is false - eliminate 1st cell candidate digit and goto next_conj_pair
endif
endfor
mark 2nd cell in entry with '+' parity (true) // begin second pass
do
assign '+' parity on coloring grid using naked/hidden singles logic
assign '-' parity on coloring grid using row/col/box interactions
until done
for each sector in 1..27
count total set '+' parity and '-' parity this pass
if count '+' parity > 1 or // multiple true
count '-' parity == total number possible candidates // all false
second premise is false - eliminate 2nd cell candidate digit and goto next_conj_pair
endif
endfor
for each cell in coloring grid 1..81 // concurrence testing
if cell parity == '+' in pass 1 and pass 2 // both true
update cell to digit
if cell parity == '-' in pass 1 and pass 2 // both false
eliminate candidate digit from cell
endfor
next_conj_pair:
continue
endfor // each entry in conj_pair table
endfor // each digit in 1..9 |
The rc/rn/cn/bn spaces in the mini grid are used for quick determination of naked/hidden singles in each sector and each cell
I flag the rc cells during initialization and the do..until passes with various bits
DIGIT_SET = 1 // if the digit is already a given
DIGIT_POSSIBLE = 2 // set for each cell that has digit as a candidate
DIGIT_POS_PASS1 = 4 // set during pass one
DIGIT_NEG_PASS1 = 8 // also set during pass one
DIGIT_POS_PASS2 = 16 // set during pass two
DIGIT_NEG_PASS2 = 32 // also set during pass two
The "trick" is to use standard sudoku techniques to "extend" the parity.
Assigning '+' parity needs to set all peers to '-' parity - ns/hs logic.
Assigning '-' parity needs to test for pointing pairs or box/lines and assign resulting '-' parity - row/col/box interaction logic.
This method leads directly from X-coloring to 3d-medusa by coloring all 9 digits simultaneously. It's a little "trickier", but 3d-medusa is one of the most powerful coloring techniques available. |
|
Back to top |
|
|
| Lunatic
| Joined: 11 Mar 2007 | Posts: 166 | : | Location: Ghent - Belgium | Items |
|
Posted: Tue May 12, 2009 3:40 am Post subject: Re: Thanks! |
|
|
Puzzler wrote: | Marc, you mentioned that this technique only works if you have a single chain. I'm finding with the test cases I have that it doesn't matter if I have more than one chain, as long as I only test one chain at a time. Is this correct, or have I just been lucky in my test cases? |
Correct, Kevin, you can only test one chain at a time in 'Simple Coloring', that's why this technique is also known as 'Single Chain'.
I can recommend you the website of Andrew C. Stewart, who did a great job on explaining most known techniques for solving sudokus >>> http://www.scanraid.com/sudoku.htm _________________ Marc
~~~<><~~~<><~~~<><~~~<><~~~ |
|
Back to top |
|
|
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
Igloo Theme Version 1.0 :: Created By: Andrew Charron
|