Meet with Expert

Friday, May 11, 2007

Resolving Sudoku by IBM's Domino

The document is related to some discoveries I had resolving Sudoku puzzle. I did this in a IBM Domino application, or call it notes database years ago. Writting code is much more enjoyable than thinking by hand, the bad thing is after I wrote the application, I had never used my brain to do it.

Normally I would need 10-20 minutes to resolve a puzzle, the quickest I did is less than 6 minutes. I am not sure whether there is a world record for human brain. for programming, it takes less than 3 seconds.

There is something I can't understand, IBM's Deep Blue can beat chess champion (though I don't know how it was possible), but for another game, computer seems useless. This is "Go Chess" or "Wei Qi" which is popular in Japan, China or South Korea. I played with a number of computer before, all of them I can beat them easily.

It have a number of ways doing it according to wiki. Below is the logic I coded, it uses same logic if I do it by hand.

1. Eliminating number for a cell.
1 to 9 can be possibly assigned to a cell. A number of figures can be eliminated if same row, same column or the 3-3-cell group has the figure. If after elimination, only one number is left for the cell, it must be right.

I tried this first, tested a few it works fine. It can not resolve all puzzles. I found I overlooked figure constraint in the 3x3 group. So I wrote the 2nd part.

2. Allocating missing number in 3x3 cell, or eliminating cell for a number.
If a number is missing in 3x3 cell, normally it can be put into a few remaining empty cells. The question is how to eliminate cells for the figure. For example, if there are 3 cells left to put fiure 1 in a 3*3 group, but 2 of them are impossible because parallel cells in same column or row has got it, the last spot is must be right.

After this, it can resolve 80% puzzles in seconds, just by one click. 20% are really hard ones. It needs to take a guess to see whether all cells can be filled for the possibility, if it fails, try a different one until it works. I use this way to resolve the rest 20%, for most difficult puzzle, I took around 2-3 mins. I reckon, the step is extremely difficult for human, this needs a great member and fast analytical skill, if doing by paper, it would mess up quickly before the person is lost.

Computer is so powerful, so great, but it is not as good as human.

No comments: