=============================================
After reading P.J. Downey's claims about his Soduko solving algorithm,
I was eager to give it a try, especially since it was so compact.
Once able to understand the "big idea", its simplicity and directness
(not to mention effectiveness) struct me as quite beautiful.
Solving Soduko puzzles by hand is a matter of elimination. One strives
to make eliminations and deductions with 100% confidence. Only when
stuck does one "guess" and hope to be on the right path.
Mr. Downey's computer algorithm, on the other hand, is 100% guess, with
the full knowledge that subsequent contradictions and backtracking will
eventually lead to the solution.
I did give Mr. Downey's algorithm a try and even made a modest improvement
(not that a few milli-seconds really make any difference). His algorithm attacks
grid cells in order, starting with cell 1 and ending with cell 81.
My idea is to pre-compute the order in which cells are attacked:
1. Choose the cells for which a value is known.
Make a list of the remaining cell positions.
2. From the remaining cell positions, choose the position most likely
to cause a conflict; that is, choose the position whose associated
constraint array references the most known grid positions.
Suppose we choose grid cell `k'.
3. Deleted position `k' from the list.
Subsequently, treat grid cell `k' as if it were known.
4. Go to step 2, as long as any positions remain.
My program is written in "C++" and run on my home computer,
using an Intel 2.26GHz Pentium 4 Processor.
Timing Comparisons:
Downey Original = .134 seconds / solution
Downey Modified = .065 seconds / solution (to include the
overhead of pre-computing the attack order)
Michael A. Deverin
devfam47@vtisp.com
2005.09.03
===============================================