- #1
arpace
- 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?
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: