Simple factorial and matrix question

if I have n slots [1,2,3,4,5,...n] where I must use numbers from 1 through n, and I have to ensure that none of them were reused...

the way I figure to make sure that none of the numbers are reused is to multiply the values in each slot and compare them against n!

e.g. [1,2,3,4,5] would be correct, but [1,4,6,3,2] or [5,5,2,1,3]

kind of like sudoku's rule for a row but not quite
[[1,2,3,4,5,6],
[6,1,2,3,4,5],
[5,6,1,2,3,4],
[4,5,6,1,2,3],
[3,4,5,6,1,2]]
that would be correct

Am I right in assuming that that n! would be useful for looping through the rows to see if they are correct? and then (n!)^(n) would be a way to validate the entire grid?

is this a rule I just don't know? is there a rule that is easier?

Last edited:

if I have n slots [1,2,3,4,5,...n] where I must use numbers from 1 through n, and I have to ensure that none of them were reused...

the way I figure to make sure that none of the numbers are reused is to multiply the values in each slot and compare them against n!

e.g. [1,2,3,4,5] would be correct, but [1,4,6,3,2] or [5,5,2,1,3]

kind of like sudoku's rule for a row but not quite
[[1,2,3,4,5,6],
[6,1,2,3,4,5],
[5,6,1,2,3,4],
[4,5,6,1,2,3],
[3,4,5,6,1,2]]
that would be correct

Am I right in assuming that that n! would be useful for looping through the rows to see if they are correct? and then (n!)^(n) would be a way to validate the entire grid?

is this a rule I just don't know? is there a rule that is easier?

Google "permutations", and yes: there are n! different ways to order in an array the numbers 1,2,...,n in such a way that each

appears exactly once.

DonAntonio