How many 9x9 sudoku grids are there




















Collectives on Stack Overflow. Learn more. Asked 10 years, 3 months ago. Active 2 years, 6 months ago. Viewed 24k times. Improve this question. Jagan Jagan 4, 17 17 gold badges 56 56 silver badges 70 70 bronze badges.

Generate all sudoku puzzles that are valid puzzles. I wrote the program for that using backtracking. But it may take years to execute. As you can see it is "impossible" with a standard computer to compute all of them. There are ways to do it using advanced combinatorics. Only thing i need is mathematical steps using permutations to find out the number. I'm voting to close this question as off-topic because it has nothing to do with programming.

Show 1 more comment. Active Oldest Votes. Improve this answer. Sven Marnach k gold badges silver badges bronze badges. Valli Valli 2 2 bronze badges. So only the numbers 4, 5, 6, 7, 8, and 9 from the second and third rows of B1 can be used in the first row in B2 and B3. Exercise: List all the possible ways of filling in the first rows in B2 and B3, up to reordering of the digits in each block.

Hint: There are ten ways of doing this so that swapping B2 and B3 in these ten ways give you ten more ways, for a total of twenty. Given these twenty possibilities for the first row of the grid up to reordering of the digits in each block , we can figure out how to complete the first band. How many total possibilities are there, counting different number orderings within each row in B2 and B3?

Remember, we want to keep B1 fixed because we've already accounted for the number of grids that can be obtained by relabeling the nine digits in it. It turns out there are 3! The answer is the same for the other pure top row, since in this case all we've done is swapped B2 with B3.

The cases of the mixed top rows are more complicated. This can be completed to the first band as in the following picture, where a, b, and c are the numbers 1, 2, 3 in any order.

Once a is picked, b and c are the remaining two numbers in any order, since they are in the same row. You can similarly work out each of the remaining seventeen cases of first rows to obtain the same number. Instead of calculating how many full grid completions each of these possibilities has, Felgenhauer and Jarvis next determined which first bands share the same number of full grid completions. Such an analysis reduces the number of first bands that need to be considered when counting.

Here are some operations which leave the number of grid completions of the first band unchanged: relabeling the numbers, permuting any of the blocks in the first band, permuting the columns within any block, and permuting the three rows of the band. When any of these changes B1, we can relabel the digits to recover its standard form.

Permuting B1, B2, and B3 preserves the number of grid completions because if we start with any valid Sudoku grid, the only way to keep it valid would be to permute B4, B5, B6 and B7, B8, B9 correspondingly so that the stacks remain the same.

In other words, every valid grid completion for the first band gives exactly one valid grid completion for the first band being any permutation of B1, B2, B3.

Exercise: Convince yourself that when you swap B2 with B3 in the following Sudoko grid, the only way to keep the grid valid is to swap B5 with B6, and B7 with B8. This keeps the stacks the same, although their locations have changed. Exercise: If you have a valid Sudoku grid and you permute the columns in any of B1, B2, and B3, what would you need to do to the columns of the rest of the Sudoku grid in order to keep it valid? For example, if you swap columns 1 and 2 of B2 in the above grid, how would you fix the resulting grid so that it satisfies the One Rule?

The last exercise tells us that each grid completion of a first band gives a unique grid completion of the first band with columns permuted within the blocks. Such considerations allow us to reduce the number of specific first bands we need to consider when counting. Following Felgenhauer and Jarvis, we permute the columns of B2 and B3 so that the top row entries of each are in increasing order, and then swap B2 and B3 if necessary to make the first entry of B2 smaller than that of B3.

This is called lexicographical reduction. Many problems in combinatorics suffer from this problem, however it does not mean that we cannot study properties of these objects. The reason for this is the freedom in producing a valid Sudoku board. When producing an exact formula is not possible, mathematicians sometimes resort to giving upper and lower bounds on the number of configurations.

The question concerning the number of different Sudoku's is even harder to answer! In problems of this type it is not immediately clear how to decide when two Sudoku grids are the same. If one rotates a Sudoku grid by 90 degrees then it is easy to see that nothing has changed. If one flips such a grid upside down then, again, it is essentially the same. However, if one changes each of the numbers 1,2,3,4,5,6,7,8,9 to the numbers 5,8,3,2,6,9,1,4,7 then is it the same?

Well, even though this may be less obvious than the other operations, yes of course. From the initial values that one is given, exactly the same reasoning is used to complete the board. There are several other similar operations that one can also do to make a new grid that looks different but is essentially the same.



0コメント

  • 1000 / 1000