Simple factorial and matrix question

  • Thread starter arpace
  • Start date
  • #1
9
0
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
e.g. if I had n=6
[[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:

Answers and Replies

  • #2
606
1
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
e.g. if I had n=6
[[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
 

Related Threads on Simple factorial and matrix question

  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
2
Views
490
  • Last Post
Replies
1
Views
3K
  • Last Post
Replies
3
Views
6K
  • Last Post
Replies
1
Views
3K
  • Last Post
Replies
5
Views
1K
  • Last Post
Replies
3
Views
3K
Replies
13
Views
1K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
3
Views
3K
Top