I have a string with numbers 1:n. I want to add a second line also with numbers 1:n, but they must be in random order, satisfying as follows:
- Both lines should not have the same number.
- No combination of numbers occurs twice
For example, in the following
Row 1: 1 2 3 4 5 6 7 ...
Row 2: 3 6 15 8 13 12 7 ...
the number 7 occurs in the same position on both lines 1 and 2 (namely, in position 7, thereby not satisfying rule 1)
and in the next
Row 1: 1 2 3 4 5 6 7 ...
Row 2: 3 7 15 8 13 12 2 ...
the combination 2 + 7 appears twice (in positions 2 and 7, thereby not satisfying rule 2).
It might have been possible, but unnecessarily laborious, to do it manually (at least to a reasonable number), but for this, MATLAB should have a pretty elegant solution.