Maths Question: number of different permutations

Posted by KingCong on Stack Overflow See other posts from Stack Overflow or by KingCong
Published on 2010-03-25T01:30:38Z Indexed on 2010/03/25 1:33 UTC
Read the original article Hit count: 508

This is more of a maths question than programming but I figure a lot of people here are pretty good at maths! :)

My question is: Given a 9 x 9 grid (81 cells) that must contain the numbers 1 to 9 each exactly 9 times, how many different grids can be produced. The order of the numbers doesn't matter, for example the first row could contain nine 1's etc. This is related to Sudoku and we know the number of valid Sudoku grids is 6.67×10^21, so since my problem isn't constrained like Sudoku by having to have each of the 9 numbers in each row, column and box then the answer should be greater than 6.67×10^21.

My first thought was that the answer is 81! however on further reflection this assume that the 81 number possible for each cell are different, distinct number. They are not, there are 81 possible numbers for each cell but only 9 possible different numbers.

My next thought was then that each of the cells in the first row can be any number between 1 and 9. If by chance the first row happened to be all the same number, say all 1s, then each cell in the second row could only have 8 possibilites, 2-9. If this continued down until the last row then number of different permutations could be calculated by 9^2 * 8^2 * 7^2 ..... * 1^2. However this doesn't work if each row doesn't contain 9 of the same number.

It's been quite a while since I studied this stuff and I can't think of a way to work it out, I'd appreciate any help anyone can offer.

© Stack Overflow or respective owner

Related posts about math

Related posts about mathematics