Pi wrote:I am entregued about how you calculate that, i have onsidered setting up a similar solver and am very interested

Basically, a backtrack program is needed to count all the solutions. We want a function numCompletions(G) which will return the number of completions of the grid G.

Then you would code it something like this - I hope its clear but I have tried to write it in a language neutral way, rather than assume that you are a C programmer, Java programmer or whatever...

- Code: Select all
`numCompletions(G) `

if G is a complete grid, then return 1

otherwise

choose an empty position, and find all legal entries for that position, call them x1, x2, .. ,xN

if there are no legal entries, then return 0

otherwise

add up the values of numCompletions(G+x1), numCompletions(G+x2), numCompletions(G+xN) and return this value

This is obviously recursive, in that numCompletions calls itself... the idea is just that you try every possible entry in a position, and then see how many ways there are of completing the grid from there.

In practice, you need to be a bit more efficient, but that is the basic idea behind a backtrack program..

Some people have solvers that attempt to emulate human logic (by working out naked singles etc etc) but for counting problems, a backtrack is ultimately needed..

Gordon